Skip to content

Commit e599f7b

Browse files
committed
Update utils.go
1 parent 614b324 commit e599f7b

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

utils/utils.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"net/http"
1414
"os"
1515
"path/filepath"
16-
"runtime"
1716
"strings"
1817

1918
"com.lc.go.codepush/client/constants"
@@ -112,10 +111,8 @@ func FileMD5(filePath string) (string, error) {
112111
}
113112

114113
func Zip(src_dir string, zip_file_name string) {
115-
prefix := `/`
116-
if runtime.GOOS == "windows" {
117-
prefix = `\`
118-
}
114+
prefix := string(os.PathSeparator)
115+
119116
// 预防:旧文件无法覆盖
120117
os.RemoveAll(zip_file_name)
121118

@@ -127,7 +124,7 @@ func Zip(src_dir string, zip_file_name string) {
127124
archive := zip.NewWriter(zipfile)
128125
defer archive.Close()
129126

130-
nowSrc := strings.ReplaceAll(strings.Replace(src_dir, "./", "", 1), "\\\\", "\\")
127+
nowSrc := strings.ReplaceAll(strings.Replace(src_dir, "./", "", 1), "\\\\", prefix)
131128
// 遍历路径信息
132129
filepath.Walk(src_dir, func(path string, info os.FileInfo, _ error) error {
133130

0 commit comments

Comments
 (0)