2024-03-13 15:31:28 +08:00
|
|
|
package syncdrive
|
|
|
|
|
|
|
|
import (
|
2024-03-17 09:33:53 +08:00
|
|
|
"fmt"
|
2024-03-16 20:44:19 +08:00
|
|
|
"io/fs"
|
|
|
|
"os"
|
2024-03-13 15:31:28 +08:00
|
|
|
"path"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetPanFileFullPathFromLocalPath 获取网盘文件的路径
|
|
|
|
func GetPanFileFullPathFromLocalPath(localFilePath, localRootPath, panRootPath string) string {
|
|
|
|
localFilePath = strings.ReplaceAll(localFilePath, "\\", "/")
|
|
|
|
localRootPath = strings.ReplaceAll(localRootPath, "\\", "/")
|
|
|
|
|
|
|
|
relativePath := strings.TrimPrefix(localFilePath, localRootPath)
|
2024-03-16 23:13:53 +08:00
|
|
|
panPath := path.Join(path.Clean(panRootPath), relativePath)
|
|
|
|
return strings.ReplaceAll(panPath, "\\", "/")
|
2024-03-13 15:31:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetLocalFileFullPathFromPanPath 获取本地文件的路径
|
|
|
|
func GetLocalFileFullPathFromPanPath(panFilePath, localRootPath, panRootPath string) string {
|
|
|
|
panFilePath = strings.ReplaceAll(panFilePath, "\\", "/")
|
|
|
|
panRootPath = strings.ReplaceAll(panRootPath, "\\", "/")
|
|
|
|
|
|
|
|
relativePath := strings.TrimPrefix(panFilePath, panRootPath)
|
|
|
|
return path.Join(path.Clean(localRootPath), relativePath)
|
|
|
|
}
|
2024-03-16 20:44:19 +08:00
|
|
|
|
|
|
|
// IsSymlinkFile 是否是软链接文件
|
|
|
|
func IsSymlinkFile(file fs.FileInfo) bool {
|
|
|
|
if file.Mode()&os.ModeSymlink != 0 {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2024-03-17 09:33:53 +08:00
|
|
|
|
2024-03-17 11:34:40 +08:00
|
|
|
// PromptPrintln 输出提示消息到控制台
|
|
|
|
func PromptPrintln(msg string) {
|
2024-03-17 09:33:53 +08:00
|
|
|
if LogPrompt {
|
2024-03-17 11:34:40 +08:00
|
|
|
//fmt.Println("[" + utils.NowTimeStr() + "] " + msg)
|
|
|
|
fmt.Println(msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PromptPrint(msg string) {
|
|
|
|
if LogPrompt {
|
|
|
|
fmt.Print(msg)
|
2024-03-17 09:33:53 +08:00
|
|
|
}
|
|
|
|
}
|