Fixed Extended Files

This commit is contained in:
Caleb Gardner
2021-01-16 03:09:48 -06:00
parent 80946f58e7
commit 17e1d65488
3 changed files with 15 additions and 18 deletions
+4 -4
View File
@@ -18,7 +18,7 @@ type fragmentEntry struct {
//GetFragmentDataFromInode returns the fragment data for a given inode.
//If the inode does not have a fragment, harmlessly returns an empty slice without an error.
func (r *Reader) getFragmentDataFromInode(in *inode.Inode) ([]byte, error) {
var size uint32
var size uint64
var fragIndex uint32
var fragOffset uint32
if in.Type == inode.FileType {
@@ -27,9 +27,9 @@ func (r *Reader) getFragmentDataFromInode(in *inode.Inode) ([]byte, error) {
return make([]byte, 0), nil
}
if bf.BlockStart == 0 {
size = bf.Size
size = uint64(bf.Size)
} else {
size = bf.BlockSizes[len(bf.BlockSizes)-1]
size = uint64(bf.BlockSizes[len(bf.BlockSizes)-1])
}
fragIndex = bf.FragmentIndex
fragOffset = bf.FragmentOffset
@@ -41,7 +41,7 @@ func (r *Reader) getFragmentDataFromInode(in *inode.Inode) ([]byte, error) {
if bf.BlockStart == 0 {
size = bf.Size
} else {
size = bf.BlockSizes[len(bf.BlockSizes)-1]
size = uint64(bf.BlockSizes[len(bf.BlockSizes)-1])
}
fragIndex = bf.FragmentIndex
fragOffset = bf.FragmentOffset
+4 -4
View File
@@ -140,8 +140,8 @@ func NewFile(rdr io.Reader, blockSize uint32) (File, error) {
//ExtFileInit is the information that can be directly decoded
type ExtFileInit struct {
BlockStart uint32
Size uint32
BlockStart uint64
Size uint64
Sparse uint64
HardLinks uint32
FragmentIndex uint32
@@ -164,8 +164,8 @@ func NewExtendedFile(rdr io.Reader, blockSize uint32) (ExtFile, error) {
return inode, err
}
inode.Fragmented = inode.FragmentIndex != 0xFFFFFFFF
blocks := inode.Size / blockSize
if inode.Size%blockSize > 0 {
blocks := inode.Size / uint64(blockSize)
if inode.Size%uint64(blockSize) > 0 {
blocks++
}
inode.BlockSizes = make([]uint32, blocks, blocks)
+7 -10
View File
@@ -15,7 +15,7 @@ import (
const (
downloadURL = "https://github.com/srevinsaju/Firefox-Appimage/releases/download/firefox-v84.0.r20201221152838/firefox-84.0.r20201221152838-x86_64.AppImage"
appImageName = "firefox-84.0.r20201221152838-x86_64.AppImage"
appImageName = "Ultimaker_Cura-4.8.0.AppImage"
squashfsName = "balenaEtcher-1.5.113-x64.AppImage.sfs"
)
@@ -71,20 +71,17 @@ func TestAppImage(t *testing.T) {
stat, _ := aiFil.Stat()
os.RemoveAll(wd + "/testing/firefox")
ai := goappimage.NewAppImage(wd + "/testing/" + appImageName)
start := time.Now()
rdr, err := NewSquashfsReader(io.NewSectionReader(aiFil, ai.Offset, stat.Size()-ai.Offset))
if err != nil {
t.Fatal(err)
}
rt := rdr.GetFileAtPath("/")
fils, err := rt.GetChildrenRecursively()
if err != nil {
t.Fatal(err)
desktop := rdr.GetFileAtPath("*.desktop")
if desktop == nil {
t.Fatal("Problema!")
}
for _, fil := range fils {
fmt.Println(fil.Path())
}
fmt.Println(time.Since(start))
os.Remove(wd + "/testing/cura.desktop")
deskFil, _ := os.Create(wd + "/testing/cura.desktop")
io.Copy(deskFil, desktop.Sys().(io.Reader))
t.Fatal("No problemo!")
}