-
Notifications
You must be signed in to change notification settings - Fork 0
/
screw_windows.go
56 lines (45 loc) · 946 Bytes
/
screw_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// +build windows
package screw
import (
"os"
"golang.org/x/sys/windows"
)
func sneakyLog(line string) {
a, err1 := windows.UTF16FromString("[sneaky-log]")
b, err2 := windows.UTF16FromString(line)
if err1 == nil && err2 == nil {
windows.DnsNameCompare(&a[0], &b[0])
}
}
func doRename(oldpath, newpath string) error {
var lastErr error
sleeper := newSleeper()
for {
err := os.Rename(oldpath, newpath)
lastErr = err
if err == nil {
break
}
if !os.IsNotExist(err) && sleeper.Sleep(err) {
continue
}
break
}
return lastErr
}
func TrueBaseName(name string) string {
var data windows.Win32finddata
utf16Str, err := windows.UTF16FromString(name)
if err != nil {
return ""
}
h, err := windows.FindFirstFile(&utf16Str[0], &data)
if err != nil {
return ""
}
_ = windows.FindClose(h)
return windows.UTF16ToString(data.FileName[:windows.MAX_PATH-1])
}
func IsCaseInsensitiveFS() bool {
return true
}