diff --git a/reader.go b/reader.go index 97dd69d..4c33fad 100644 --- a/reader.go +++ b/reader.go @@ -114,6 +114,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) diff --git a/squash_test.go b/squash_test.go index cbbd243..cd79d6f 100644 --- a/squash_test.go +++ b/squash_test.go @@ -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) }