Added Reader.ExtractTo for ease of use
This commit is contained in:
@@ -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)
|
||||
|
||||
+1
-5
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user