Files
skillshare/internal/utils/path.go
T
Willie Hung 0f7ba6ff8d fix(windows): improve junction error messages and path comparison
- Add detailed error messages when junction/symlink creation fails
  - Pre-flight checks for source existence and target conflicts
  - Capture mklink /J stderr output
  - Show both junction and symlink failure reasons

- Add case-insensitive path comparison for Windows (NTFS)
  - New PathsEqual() and PathHasPrefix() in utils/path.go
  - Fix 8 path comparisons that could fail due to case differences
  - Affects sync, pull, target remove, diff, and doctor commands
2026-01-31 16:50:39 +08:00

27 lines
690 B
Go

package utils
import (
"runtime"
"strings"
)
// PathsEqual compares two paths for equality.
// On Windows, paths are compared case-insensitively since NTFS is case-insensitive.
// On Unix systems, paths are compared exactly.
func PathsEqual(a, b string) bool {
if runtime.GOOS == "windows" {
return strings.EqualFold(a, b)
}
return a == b
}
// PathHasPrefix checks if path starts with prefix.
// On Windows, comparison is case-insensitive.
// On Unix systems, comparison is exact.
func PathHasPrefix(path, prefix string) bool {
if runtime.GOOS == "windows" {
return strings.HasPrefix(strings.ToLower(path), strings.ToLower(prefix))
}
return strings.HasPrefix(path, prefix)
}