mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 22:42:15 +08:00
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
package syncdrive
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
"path"
|
|
"strings"
|
|
)
|
|
|
|
// GetPanFileFullPathFromLocalPath 获取网盘文件的路径
|
|
func GetPanFileFullPathFromLocalPath(localFilePath, localRootPath, panRootPath string) string {
|
|
localFilePath = strings.ReplaceAll(localFilePath, "\\", "/")
|
|
localRootPath = strings.ReplaceAll(localRootPath, "\\", "/")
|
|
|
|
relativePath := strings.TrimPrefix(localFilePath, localRootPath)
|
|
return path.Join(path.Clean(panRootPath), relativePath)
|
|
}
|
|
|
|
// 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)
|
|
}
|
|
|
|
// IsSymlinkFile 是否是软链接文件
|
|
func IsSymlinkFile(file fs.FileInfo) bool {
|
|
if file.Mode()&os.ModeSymlink != 0 {
|
|
return true
|
|
}
|
|
return false
|
|
}
|