返回 DeepSeek-Reasonix
path_case_windows.go
根目录 / internal / repair / path_case_windows.go
1 //go:build windows
2
3 package repair
4
5 import (
6 "encoding/binary"
7
8 "golang.org/x/sys/windows"
9 )
10
11 func platformRepairPathCaseInsensitive(path string) bool {
12 parent := existingRepairPathParent(path)
13 if parent == "" {
14 return true
15 }
16 name, err := windows.UTF16PtrFromString(parent)
17 if err != nil {
18 return true
19 }
20 handle, err := windows.CreateFile(
21 name,
22 windows.FILE_READ_ATTRIBUTES,
23 windows.FILE_SHARE_READ|windows.FILE_SHARE_WRITE|windows.FILE_SHARE_DELETE,
24 nil,
25 windows.OPEN_EXISTING,
26 windows.FILE_FLAG_BACKUP_SEMANTICS,
27 0,
28 )
29 if err != nil {
30 return true
31 }
32 defer windows.CloseHandle(handle)
33
34 var info [4]byte
35 err = windows.GetFileInformationByHandleEx(
36 handle,
37 windows.FileCaseSensitiveInfo,
38 &info[0],
39 uint32(len(info)),
40 )
41 if err == nil {
42 return binary.LittleEndian.Uint32(info[:])&windows.FILE_CS_FLAG_CASE_SENSITIVE_DIR == 0
43 }
44 // Per-directory case sensitivity was added after the API itself. Systems
45 // that cannot answer the query retain legacy case-insensitive lookup.
46 return true
47 }
48
48 lines GO