From 97980e61bead4aa74663113a417c569ad8a7c985 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 22 Jul 2026 22:04:55 +0200 Subject: [PATCH] fs: remove some hard-coded path-separators Some implementations are called out to be incomplete on Windows; let's at least fix some hard-coded path-separators. Signed-off-by: Sebastiaan van Stijn --- fs/diff.go | 2 +- fs/path.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/diff.go b/fs/diff.go index ea170705..2f2cce4a 100644 --- a/fs/diff.go +++ b/fs/diff.go @@ -253,7 +253,7 @@ func DiffDirChanges(ctx context.Context, baseDir, diffDir string, source DiffSou if kind == ChangeKindAdd || kind == ChangeKindDelete { parent := filepath.Dir(path) - if _, ok := changedDirs[parent]; !ok && parent != "/" { + if _, ok := changedDirs[parent]; !ok && parent != string(os.PathSeparator) { pi, err := os.Stat(filepath.Join(diffDir, parent)) if err := changeFn(ChangeKindModify, parent, pi, err); err != nil { return err diff --git a/fs/path.go b/fs/path.go index ec6e6a2f..d8b546c3 100644 --- a/fs/path.go +++ b/fs/path.go @@ -235,7 +235,7 @@ func RootPath(root, path string) (string, error) { } path = newpath if i == linksWalked { - newpath = filepath.Join("/", newpath) + newpath = filepath.Join(string(os.PathSeparator), newpath) if path == newpath { return filepath.Join(root, newpath), nil } @@ -249,8 +249,8 @@ func walkLink(root, path string, linksWalked *int) (newpath string, islink bool, return "", false, errTooManyLinks } - path = filepath.Join("/", path) - if path == "/" { + path = filepath.Join(string(os.PathSeparator), path) + if path == string(os.PathSeparator) { return path, false, nil } realPath := filepath.Join(root, path) @@ -281,7 +281,7 @@ func walkLinks(root, path string, linksWalked *int) (string, error) { return newpath, err case file == "": if os.IsPathSeparator(dir[len(dir)-1]) { - if dir == "/" { + if dir == string(os.PathSeparator) { return dir, nil } return walkLinks(root, dir[:len(dir)-1], linksWalked)