fix local windows path recognize error

This commit is contained in:
tickstep
2025-03-08 10:14:12 +08:00
parent 4f7941caf5
commit 3d87c6244f
3 changed files with 5 additions and 11 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ func CmdLocalPwd() cli.Command {
// Unix-like system, so just assume Unix
lwd = strings.ReplaceAll(lwd, "\\", "/")
}
fmt.Println(lwd)
fmt.Println("本地工作目录: " + lwd)
return nil
},
}
+1 -8
View File
@@ -28,13 +28,6 @@ import (
"strings"
)
type ()
const (
opLs int = iota
opSearch
)
func CmdLocalLs() cli.Command {
return cli.Command{
Name: "lls",
@@ -216,7 +209,7 @@ func renderTable(path string, files []os.FileInfo) {
totalSize += file.Size()
tb.Append([]string{strconv.Itoa(k + 1), converter.ConvertFileSize(file.Size(), 2), file.ModTime().Format("2006-01-02 15:04:05"), file.Name()})
}
tb.Append([]string{"", "总大小: " + converter.ConvertFileSize(totalSize, 2), "", fmt.Sprintf("文件总数: %d, 目录总数: %d", fileCount, dirCount)})
tb.Append([]string{"", "总: " + converter.ConvertFileSize(totalSize, 2), "", fmt.Sprintf("文件总数: %d, 目录总数: %d", fileCount, dirCount)})
fmt.Printf("\n本地当前目录: %s\n", path)
fmt.Printf("----\n")
+3 -2
View File
@@ -5,6 +5,7 @@ import (
"github.com/tickstep/aliyunpan/library/homedir"
"os"
"path"
"path/filepath"
"strings"
)
@@ -19,8 +20,8 @@ func getLocalHomeDir() string {
// localPathJoin 拼接本地路径
func localPathJoin(p string) string {
p = strings.ReplaceAll(p, "\\", "/")
if path.IsAbs(p) {
p = path.Clean(strings.ReplaceAll(p, "\\", "/"))
if filepath.IsAbs(p) {
return p
} else if strings.HasPrefix(p, "~") {
if d, e := homedir.Expand(p); e == nil {