From 9d6cb46d671aeb08d1fb0fc386b32b8c8f1da100 Mon Sep 17 00:00:00 2001 From: qydysky Date: Tue, 25 Feb 2025 10:15:02 +0800 Subject: [PATCH] 1 (#30) * 1 * 1 --- file/FileWR.go | 2 +- file/FileWR_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/file/FileWR.go b/file/FileWR.go index 3c39b97..f394213 100644 --- a/file/FileWR.go +++ b/file/FileWR.go @@ -847,7 +847,7 @@ func (t *File) newPath(path string, mode fs.FileMode) { if !filepath.IsAbs(path) { rawPath, _ = os.Getwd() } - rawPs := strings.Split(path, string(os.PathSeparator)) + rawPs := strings.Split(strings.ReplaceAll(path, `\`, `/`), `/`) for n, p := range rawPs { if p == "" || p == "." { continue diff --git a/file/FileWR_test.go b/file/FileWR_test.go index 8a8104d..3ab50d0 100644 --- a/file/FileWR_test.go +++ b/file/FileWR_test.go @@ -29,6 +29,10 @@ func TestDirFs(t *testing.T) { } } +func TestPathSeparator(t *testing.T) { + New("./testdata/l/0.txt", 0, false).Create() +} + func TestNewPath2(t *testing.T) { os.RemoveAll("./test") time.Sleep(time.Second) -- 2.39.2