Compare commits

...

2 Commits

Author SHA1 Message Date
Caleb Gardner 6dfcb1cf80 Merge branch 'main' of https://github.com/CalebQ42/squashfs into main 2020-12-10 08:52:58 -06:00
Caleb Gardner c7593eaff3 Added Reader.ExtractTo for ease of use 2020-12-10 08:52:49 -06:00
2 changed files with 10 additions and 5 deletions
+9
View File
@@ -148,6 +148,15 @@ func NewSquashfsReader(r io.ReaderAt) (*Reader, error) {
return &rdr, nil
}
//ExtractTo tries to extract ALL files to the given path. This is the same as getting the root folder and extracting that.
func (r *Reader) ExtractTo(path string) []error {
root, err := r.GetRootFolder()
if err != nil {
return []error{err}
}
return root.ExtractTo(path)
}
//GetRootFolder returns a squashfs.File that references the root directory of the squashfs archive.
func (r *Reader) GetRootFolder() (root *File, err error) {
root = new(File)
+1 -5
View File
@@ -58,11 +58,7 @@ func TestAppImage(t *testing.T) {
if err != nil {
t.Fatal(err)
}
fil := rdr.GetFileAtPath(".DirIcon")
if fil == nil {
t.Fatal("Can't find desktop file")
}
errs := fil.ExtractSymlink(wd + "/testing/")
errs := rdr.ExtractTo(wd + "/testing/cool-retro")
if len(errs) > 0 {
t.Fatal(errs)
}