This commit is contained in:
Caleb Gardner
2021-01-16 15:43:04 -06:00
5 changed files with 32 additions and 29 deletions
+3 -3
View File
@@ -203,7 +203,7 @@ func (f *File) IsDir() bool {
//IsSymlink returns if the file is a symlink.
func (f *File) IsSymlink() bool {
return f.filType == inode.SymType || f.filType == inode.ExtSymlinkType
return f.filType == inode.SymType || f.filType == inode.ExtSymType
}
//IsFile returns if the file is a file.
@@ -217,8 +217,8 @@ func (f *File) SymlinkPath() string {
switch f.filType {
case inode.SymType:
return f.in.Info.(inode.Sym).Path
case inode.ExtSymlinkType:
return f.in.Info.(inode.Sym).Path
case inode.ExtSymType:
return f.in.Info.(inode.ExtSym).Path
default:
return ""
}
+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
+7 -6
View File
@@ -16,7 +16,7 @@ const (
SocketType
ExtDirType
ExtFileType
ExtSymlinkType
ExtSymType
ExtBlockDeviceType
ExtCharDeviceType
ExtFifoType
@@ -67,7 +67,8 @@ func NewExtendedDirectory(rdr io.Reader) (ExtDir, error) {
return inode, err
}
for i := uint16(0); i < inode.IndexCount; i++ {
tmp, err := NewDirectoryIndex(rdr)
var tmp DirIndex
tmp, err = NewDirectoryIndex(rdr)
if err != nil {
return inode, err
}
@@ -139,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
@@ -163,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)
+11 -6
View File
@@ -31,13 +31,15 @@ func ProcessInode(br io.Reader, blockSize uint32) (*Inode, error) {
}
info = inode
case FileType:
inode, err := NewFile(br, blockSize)
var inode File
inode, err = NewFile(br, blockSize)
if err != nil {
return nil, err
}
info = inode
case SymType:
inode, err := NewSymlink(br)
var inode Sym
inode, err = NewSymlink(br)
if err != nil {
return nil, err
}
@@ -71,19 +73,22 @@ func ProcessInode(br io.Reader, blockSize uint32) (*Inode, error) {
}
info = inode
case ExtDirType:
inode, err := NewExtendedDirectory(br)
var inode ExtDir
inode, err = NewExtendedDirectory(br)
if err != nil {
return nil, err
}
info = inode
case ExtFileType:
inode, err := NewExtendedFile(br, blockSize)
var inode ExtFile
inode, err = NewExtendedFile(br, blockSize)
if err != nil {
return nil, err
}
info = inode
case ExtSymlinkType:
inode, err := NewExtendedSymlink(br)
case ExtSymType:
var inode ExtSym
inode, err = NewExtendedSymlink(br)
if err != nil {
return nil, err
}
+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!")
}