diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2017-02-06 09:06:37 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2017-02-06 09:06:37 -0500 |
| commit | 0dc6e92cd018aa0ecea5349a14599279e1a2a574 (patch) | |
| tree | 81e071239c7a0c5bd9e7d1edbcf25bd9913f656e /lib/archive/unarchive.go | |
| parent | c7ab6d7782486fda6d6327ba8306e474daef677a (diff) | |
| download | steam-export-old_dev.tar.gz steam-export-old_dev.tar.xz | |
Simplified the Archive library. Added a way to pull the config from the web applicationold_dev
Diffstat (limited to 'lib/archive/unarchive.go')
| -rw-r--r-- | lib/archive/unarchive.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/archive/unarchive.go b/lib/archive/unarchive.go index 8a5617e..463216f 100644 --- a/lib/archive/unarchive.go +++ b/lib/archive/unarchive.go @@ -12,25 +12,24 @@ import ( "strings" ) -type Unarchive struct { - Input string - tarReader *tar.Reader -} - // Extracts a tar arcive to the current working directory // This will overwrite everything. So be careful -func (u *Unarchive) UnTar(compressionType string) error { - f, err := os.Open(u.Input) +func UnTarFromFile(InputFile, compressionType string) error { + r, err := os.Open(InputFile) if err != nil { return err } - defer f.Close() + defer r.Close() + + return UnTar(r, compressionType) +} +func UnTar(r io.Reader, compressionType string) error { var treader *tar.Reader switch compressionType { case "gz": - gzreader, err := gzip.NewReader(f) + gzreader, err := gzip.NewReader(r) if err != nil { return err } @@ -38,7 +37,7 @@ func (u *Unarchive) UnTar(compressionType string) error { treader = tar.NewReader(gzreader) default: // Read from the file directly - treader = tar.NewReader(f) + treader = tar.NewReader(r) } for { |
