From d49b443340b430cc3744251f95230491b2f2c66f Mon Sep 17 00:00:00 2001 From: Stanley Shyiko Date: Sat, 18 Nov 2017 14:50:29 -0800 Subject: [PATCH] Fixed zip/tgz handling on Windows (#116) --- command/install.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/command/install.go b/command/install.go index 0615a3e..9afbf3c 100644 --- a/command/install.go +++ b/command/install.go @@ -402,7 +402,7 @@ func untgz(source string, target string, strip bool) error { dir = filepath.Clean(header.Name) } if prefix != nil { - dirSplit := strings.Split(dir, "/") + dirSplit := strings.Split(dir, string(filepath.Separator)) i, e, dse := 0, len(prefix), len(dirSplit) if dse < e { e = dse @@ -415,10 +415,10 @@ func untgz(source string, target string, strip bool) error { i++ } } else { - prefix = strings.Split(dir, "/") + prefix = strings.Split(dir, string(filepath.Separator)) } } - prefixToStrip = strings.Join(prefix, "/") + prefixToStrip = strings.Join(prefix, string(filepath.Separator)) } gzFile.Seek(0, 0) gzr, err := gzip.NewReader(gzFile) @@ -493,7 +493,7 @@ func unzip(source string, target string, strip bool) error { dir = filepath.Clean(f.Name) } if prefix != nil { - dirSplit := strings.Split(dir, "/") + dirSplit := strings.Split(dir, string(filepath.Separator)) i, e, dse := 0, len(prefix), len(dirSplit) if dse < e { e = dse @@ -506,10 +506,10 @@ func unzip(source string, target string, strip bool) error { i++ } } else { - prefix = strings.Split(dir, "/") + prefix = strings.Split(dir, string(filepath.Separator)) } } - prefixToStrip = strings.Join(prefix, "/") + prefixToStrip = strings.Join(prefix, string(filepath.Separator)) } dirCache := make(map[string]bool) // todo: radix tree would perform better here //println("mkdir -p " + target)