diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2017-01-17 00:17:27 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2017-01-17 00:17:27 -0500 |
| commit | 9c1a057756c8f1ef486642699e45a9fa6df0b071 (patch) | |
| tree | d5ec7b19833ba0fd69be544c6facf1cea4622ce6 /archive/unarchive.go | |
| parent | 4cdac3c00a8710ead5d709428c08cc69d3b4bd27 (diff) | |
| download | steam-export-9c1a057756c8f1ef486642699e45a9fa6df0b071.tar.gz steam-export-9c1a057756c8f1ef486642699e45a9fa6df0b071.tar.xz | |
Changes to archive handling to improve cross-platform compatibility
Diffstat (limited to 'archive/unarchive.go')
| -rw-r--r-- | archive/unarchive.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/archive/unarchive.go b/archive/unarchive.go index d283d4e..8a5617e 100644 --- a/archive/unarchive.go +++ b/archive/unarchive.go @@ -8,6 +8,8 @@ import ( "io" "os" + + "strings" ) type Unarchive struct { @@ -49,21 +51,26 @@ func (u *Unarchive) UnTar(compressionType string) error { return err } + // Fix windows slashes... + fileName := strings.Replace(hdr.Name, "\\", "/", -1) + info := hdr.FileInfo() if info.IsDir() { - if err = os.MkdirAll(hdr.Name, info.Mode()); err != nil { + // 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(hdr.Name), info.Mode()); err != nil { + if err = os.MkdirAll(fp.Dir(fileName), 0775); err != nil { return err } // Create a file handle to work with - // f, err := os.Create(hdr.Name) - f, err := os.OpenFile(hdr.Name, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, info.Mode()) + // 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 } |
