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. //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. //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) { func (r *Reader) getFragmentDataFromInode(in *inode.Inode) ([]byte, error) {
var size uint32 var size uint64
var fragIndex uint32 var fragIndex uint32
var fragOffset uint32 var fragOffset uint32
if in.Type == inode.FileType { if in.Type == inode.FileType {
@@ -27,9 +27,9 @@ func (r *Reader) getFragmentDataFromInode(in *inode.Inode) ([]byte, error) {
return make([]byte, 0), nil return make([]byte, 0), nil
} }
if bf.BlockStart == 0 { if bf.BlockStart == 0 {
size = bf.Size size = uint64(bf.Size)
} else { } else {
size = bf.BlockSizes[len(bf.BlockSizes)-1] size = uint64(bf.BlockSizes[len(bf.BlockSizes)-1])
} }
fragIndex = bf.FragmentIndex fragIndex = bf.FragmentIndex
fragOffset = bf.FragmentOffset fragOffset = bf.FragmentOffset
@@ -41,7 +41,7 @@ func (r *Reader) getFragmentDataFromInode(in *inode.Inode) ([]byte, error) {
if bf.BlockStart == 0 { if bf.BlockStart == 0 {
size = bf.Size size = bf.Size
} else { } else {
size = bf.BlockSizes[len(bf.BlockSizes)-1] size = uint64(bf.BlockSizes[len(bf.BlockSizes)-1])
} }
fragIndex = bf.FragmentIndex fragIndex = bf.FragmentIndex
fragOffset = bf.FragmentOffset 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 //ExtFileInit is the information that can be directly decoded
type ExtFileInit struct { type ExtFileInit struct {
BlockStart uint32 BlockStart uint64
Size uint32 Size uint64
Sparse uint64 Sparse uint64
HardLinks uint32 HardLinks uint32
FragmentIndex uint32 FragmentIndex uint32
@@ -164,8 +164,8 @@ func NewExtendedFile(rdr io.Reader, blockSize uint32) (ExtFile, error) {
return inode, err return inode, err
} }
inode.Fragmented = inode.FragmentIndex != 0xFFFFFFFF inode.Fragmented = inode.FragmentIndex != 0xFFFFFFFF
blocks := inode.Size / blockSize blocks := inode.Size / uint64(blockSize)
if inode.Size%blockSize > 0 { if inode.Size%uint64(blockSize) > 0 {
blocks++ blocks++
} }
inode.BlockSizes = make([]uint32, blocks, blocks) inode.BlockSizes = make([]uint32, blocks, blocks)
+7 -10
View File
@@ -15,7 +15,7 @@ import (
const ( const (
downloadURL = "https://github.com/srevinsaju/Firefox-Appimage/releases/download/firefox-v84.0.r20201221152838/firefox-84.0.r20201221152838-x86_64.AppImage" 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" squashfsName = "balenaEtcher-1.5.113-x64.AppImage.sfs"
) )
@@ -71,20 +71,17 @@ func TestAppImage(t *testing.T) {
stat, _ := aiFil.Stat() stat, _ := aiFil.Stat()
os.RemoveAll(wd + "/testing/firefox") os.RemoveAll(wd + "/testing/firefox")
ai := goappimage.NewAppImage(wd + "/testing/" + appImageName) ai := goappimage.NewAppImage(wd + "/testing/" + appImageName)
start := time.Now()
rdr, err := NewSquashfsReader(io.NewSectionReader(aiFil, ai.Offset, stat.Size()-ai.Offset)) rdr, err := NewSquashfsReader(io.NewSectionReader(aiFil, ai.Offset, stat.Size()-ai.Offset))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
rt := rdr.GetFileAtPath("/") desktop := rdr.GetFileAtPath("*.desktop")
fils, err := rt.GetChildrenRecursively() if desktop == nil {
if err != nil { t.Fatal("Problema!")
t.Fatal(err)
} }
for _, fil := range fils { os.Remove(wd + "/testing/cura.desktop")
fmt.Println(fil.Path()) deskFil, _ := os.Create(wd + "/testing/cura.desktop")
} io.Copy(deskFil, desktop.Sys().(io.Reader))
fmt.Println(time.Since(start))
t.Fatal("No problemo!") t.Fatal("No problemo!")
} }