From 32bd830681f7cabb01b65709d2291308e6ba104c Mon Sep 17 00:00:00 2001 From: godo Date: Tue, 10 Sep 2024 17:34:42 +0800 Subject: [PATCH] change dir --- godo/localchat/filedown.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/godo/localchat/filedown.go b/godo/localchat/filedown.go index 0ee0b6a..d9ba98b 100644 --- a/godo/localchat/filedown.go +++ b/godo/localchat/filedown.go @@ -34,6 +34,7 @@ import ( "os" "path/filepath" "runtime" + "strings" "time" ) @@ -94,8 +95,8 @@ func handleResponse(reader io.Reader, ip string) error { log.Printf("Received file list: %v", fileList) for _, file := range fileList { - if runtime.GOOS != "windows" && containsBackslash(file.WritePath) { - file.WritePath = filepath.FromSlash(file.WritePath) + if runtime.GOOS != "windows" && strings.Contains(file.WritePath, "\\") { + file.WritePath = strings.ReplaceAll(file.WritePath, "\\", "/") } checkpath := filepath.Join(receiveDir, file.WritePath) @@ -111,11 +112,6 @@ func handleResponse(reader io.Reader, ip string) error { return nil } -// containsBackslash 检查字符串中是否包含反斜杠 -func containsBackslash(s string) bool { - return filepath.Separator == '\\' && filepath.VolumeName(s) == "" -} - // downloadFile 下载单个文件 func downloadFile(filePath string, checkpath string, ip string) error { url := fmt.Sprintf("http://%s:56780/localchat/servefile?path=%s", ip, filePath)