aboutsummaryrefslogtreecommitdiff
path: root/archive/unarchive.go
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2020-11-20 22:48:46 -0500
committerMitch Riedstra <mitch@riedstra.us>2020-11-20 22:48:46 -0500
commit78712527eed66929b8147e04d18f000dcb7dfff6 (patch)
tree612e0a4110072eab973dfa930ba04de59c06020a /archive/unarchive.go
parent891447f0e40a6d1a9637b3333cffed8eb2543c51 (diff)
downloadsteam-export-78712527eed66929b8147e04d18f000dcb7dfff6.tar.gz
steam-export-78712527eed66929b8147e04d18f000dcb7dfff6.tar.xz
Remove dead code. Remove 32 bit windows builds.
Diffstat (limited to 'archive/unarchive.go')
-rw-r--r--archive/unarchive.go85
1 files changed, 0 insertions, 85 deletions
diff --git a/archive/unarchive.go b/archive/unarchive.go
deleted file mode 100644
index 8a5617e..0000000
--- a/archive/unarchive.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package archive
-
-import (
- "archive/tar"
- fp "path/filepath"
-
- "compress/gzip"
-
- "io"
- "os"
-
- "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)
- if err != nil {
- return err
- }
- defer f.Close()
-
- var treader *tar.Reader
-
- switch compressionType {
- case "gz":
- gzreader, err := gzip.NewReader(f)
- if err != nil {
- return err
- }
- // Read from the gzip reader instead of the file
- treader = tar.NewReader(gzreader)
- default:
- // Read from the file directly
- treader = tar.NewReader(f)
- }
-
- for {
- hdr, err := treader.Next()
- if err == io.EOF {
- // We've reached the end! Whoee
- break
- }
- if err != nil {
- return err
- }
-
- // Fix windows slashes...
- fileName := strings.Replace(hdr.Name, "\\", "/", -1)
-
- info := hdr.FileInfo()
- if info.IsDir() {
- // I don't like hard-coded permissions but it
- // it helps with overall platform compatibility
- if err = os.MkdirAll(fileName, 0775); err != nil {
- return err
- }
- continue
- }
-
- if err = os.MkdirAll(fp.Dir(fileName), 0775); err != nil {
- return err
- }
-
- // Create a file handle to work with
- // f, err := os.Create(fileName)
- f, err := os.OpenFile(fileName, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0664)
- if err != nil {
- return err
- }
- defer f.Close()
- if _, err := io.Copy(f, treader); err != nil {
- return err
- }
-
- }
-
- return nil
-}