diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2020-11-20 22:48:46 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2020-11-20 22:48:46 -0500 |
| commit | 78712527eed66929b8147e04d18f000dcb7dfff6 (patch) | |
| tree | 612e0a4110072eab973dfa930ba04de59c06020a /archive/archive.go | |
| parent | 891447f0e40a6d1a9637b3333cffed8eb2543c51 (diff) | |
| download | steam-export-78712527eed66929b8147e04d18f000dcb7dfff6.tar.gz steam-export-78712527eed66929b8147e04d18f000dcb7dfff6.tar.xz | |
Remove dead code. Remove 32 bit windows builds.
Diffstat (limited to 'archive/archive.go')
| -rw-r--r-- | archive/archive.go | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/archive/archive.go b/archive/archive.go deleted file mode 100644 index 313c062..0000000 --- a/archive/archive.go +++ /dev/null @@ -1,103 +0,0 @@ -package archive - -import ( - "archive/tar" - "path/filepath" - - "compress/gzip" - - "io" - "os" - - "strings" -) - -type Archive struct { - Output string - Input []string - file *os.File -} - -func (a *Archive) Tar(compressionType string) error { - var err error - if a.file, err = os.Create(a.Output); err != nil { - return err - } - - defer a.file.Close() - - var twriter *tar.Writer - - // Set the compression type... if any - switch compressionType { - case "gz": - gzwriter, err := gzip.NewWriterLevel(a.file, gzip.BestSpeed) - if err != nil { - return err - } - defer gzwriter.Close() - // Write to the gzip writer - twriter = tar.NewWriter(gzwriter) - default: - // Write directly to the file - twriter = tar.NewWriter(a.file) - } - - // Close off the tar writer when we're done - defer twriter.Close() - - for _, v := range a.Input { - if err := filepath.Walk(v, TarWalkfn(twriter)); err != nil { - return err - } - } - - return nil - -} - -func TarWalkfn(writer *tar.Writer) filepath.WalkFunc { - return func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - - if info.IsDir() { - return nil - } - - f, err := os.Open(path) - if err != nil { - return err - } - defer f.Close() - - // Convert Windows paths to Unix paths - path = strings.Replace(path, "\\", "/", -1) - - // TODO; See if tar.FileInfoheader() could be used instead - // without the pathing issues I encountered - h := &tar.Header{ - Name: path, - Size: info.Size(), - // I don't like it... but it helps with platform compatibility - Mode: 0664, - ModTime: info.ModTime(), - } - - err = writer.WriteHeader(h) - if err != nil { - return err - } - - _, err = io.Copy(writer, f) - if err != nil { - // TODO: Figure out how to add more useful information to - // These errors - // fmt.Fprintln(os.Stderr, f.Name()) - return err - } - - return nil - } -} |
