|
@ -34,6 +34,7 @@ import ( |
|
|
"os" |
|
|
"os" |
|
|
"path/filepath" |
|
|
"path/filepath" |
|
|
"runtime" |
|
|
"runtime" |
|
|
|
|
|
"strings" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@ -94,8 +95,8 @@ func handleResponse(reader io.Reader, ip string) error { |
|
|
log.Printf("Received file list: %v", fileList) |
|
|
log.Printf("Received file list: %v", fileList) |
|
|
|
|
|
|
|
|
for _, file := range fileList { |
|
|
for _, file := range fileList { |
|
|
if runtime.GOOS != "windows" && containsBackslash(file.WritePath) { |
|
|
if runtime.GOOS != "windows" && strings.Contains(file.WritePath, "\\") { |
|
|
file.WritePath = filepath.FromSlash(file.WritePath) |
|
|
file.WritePath = strings.ReplaceAll(file.WritePath, "\\", "/") |
|
|
} |
|
|
} |
|
|
checkpath := filepath.Join(receiveDir, file.WritePath) |
|
|
checkpath := filepath.Join(receiveDir, file.WritePath) |
|
|
|
|
|
|
|
@ -111,11 +112,6 @@ func handleResponse(reader io.Reader, ip string) error { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// containsBackslash 检查字符串中是否包含反斜杠
|
|
|
|
|
|
func containsBackslash(s string) bool { |
|
|
|
|
|
return filepath.Separator == '\\' && filepath.VolumeName(s) == "" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// downloadFile 下载单个文件
|
|
|
// downloadFile 下载单个文件
|
|
|
func downloadFile(filePath string, checkpath string, ip string) error { |
|
|
func downloadFile(filePath string, checkpath string, ip string) error { |
|
|
url := fmt.Sprintf("http://%s:56780/localchat/servefile?path=%s", ip, filePath) |
|
|
url := fmt.Sprintf("http://%s:56780/localchat/servefile?path=%s", ip, filePath) |
|
|