aliyunpan/internal/syncdrive/sync_db_util.go
2022-08-09 19:27:46 +08:00

24 lines
447 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package syncdrive
import (
"path"
"regexp"
"strings"
)
// FormatFilePath 格式化文件路径
func FormatFilePath(filePath string) string {
if filePath == "" {
return ""
}
// 是否是windows路径
matched, _ := regexp.MatchString("^([a-zA-Z]:)", filePath)
if matched {
// 去掉卷标签例如D:
filePath = string([]rune(filePath)[2:])
}
filePath = strings.ReplaceAll(filePath, "\\", "/")
return path.Clean(filePath)
}