返回 DeepSeek-Reasonix
path_case_darwin.go
根目录 / internal / repair / path_case_darwin.go
1 //go:build darwin
2
3 package repair
4
5 import (
6 "strings"
7 "syscall"
8
9 "golang.org/x/sys/unix"
10 "golang.org/x/text/unicode/norm"
11 )
12
13 const darwinPathconfCaseSensitive = 11
14
15 func platformRepairPathCaseInsensitive(path string) bool {
16 parent := existingRepairPathParent(path)
17 if parent == "" {
18 return false
19 }
20 caseSensitive, err := syscall.Pathconf(parent, darwinPathconfCaseSensitive)
21 return err == nil && caseSensitive == 0
22 }
23
24 func platformRepairPathUnicodeNormalized(path string) string {
25 parent := existingRepairPathParent(path)
26 if parent == "" {
27 return path
28 }
29 var stat unix.Statfs_t
30 if err := unix.Statfs(parent, &stat); err != nil {
31 return path
32 }
33 fsType := strings.TrimRight(string(stat.Fstypename[:]), "\x00")
34 if fsType != "apfs" && fsType != "hfs" {
35 return path
36 }
37 return norm.NFD.String(path)
38 }
39
39 lines GO