Skip to content

Commit 079fb80

Browse files
committed
pkg/system: replace more uses of "syscall"
follow-up to 069fdc8, replacing more uses of the syscall package in favor of their "windows" equivalents in golang.org/x/sys. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 6004b9a commit 079fb80

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

pkg/system/path_windows.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
package system // import "github.com/docker/docker/pkg/system"
22

3-
import "syscall"
3+
import "golang.org/x/sys/windows"
44

55
// GetLongPathName converts Windows short pathnames to full pathnames.
66
// For example C:\Users\ADMIN~1 --> C:\Users\Administrator.
77
// It is a no-op on non-Windows platforms
88
func GetLongPathName(path string) (string, error) {
99
// See https://groups.google.com/forum/#!topic/golang-dev/1tufzkruoTg
10-
p := syscall.StringToUTF16(path)
10+
p, err := windows.UTF16FromString(path)
11+
if err != nil {
12+
return "", err
13+
}
1114
b := p // GetLongPathName says we can reuse buffer
12-
n, err := syscall.GetLongPathName(&p[0], &b[0], uint32(len(b)))
15+
n, err := windows.GetLongPathName(&p[0], &b[0], uint32(len(b)))
1316
if err != nil {
1417
return "", err
1518
}
1619
if n > uint32(len(b)) {
1720
b = make([]uint16, n)
18-
_, err = syscall.GetLongPathName(&p[0], &b[0], uint32(len(b)))
21+
_, err = windows.GetLongPathName(&p[0], &b[0], uint32(len(b)))
1922
if err != nil {
2023
return "", err
2124
}
2225
}
23-
return syscall.UTF16ToString(b), nil
26+
return windows.UTF16ToString(b), nil
2427
}

0 commit comments

Comments
 (0)