You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: internal/vfs/osvfs/realpath_windows.go
+18-4
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,25 @@ import (
11
11
// This implementation is based on what Node's fs.realpath.native does, via libuv: https://github.com/libuv/libuv/blob/ec5a4b54f7da7eeb01679005c615fee9633cdb3b/src/win/fs.c#L2937
12
12
13
13
funcrealpath(pathstring) (string, error) {
14
-
h, err:=openMetadata(path)
15
-
iferr!=nil {
16
-
return"", err
14
+
varh windows.Handle
15
+
iflen(path) <248 {
16
+
varerrerror
17
+
h, err=openMetadata(path)
18
+
iferr!=nil {
19
+
return"", err
20
+
}
21
+
deferwindows.CloseHandle(h) //nolint:errcheck
22
+
} else {
23
+
// For long paths, defer to os.Open to run the path through fixLongPath.
24
+
f, err:=os.Open(path)
25
+
iferr!=nil {
26
+
return"", err
27
+
}
28
+
deferf.Close()
29
+
30
+
// Works on directories too since https://go.dev/cl/405275.
31
+
h=windows.Handle(f.Fd())
17
32
}
18
-
deferwindows.CloseHandle(h) //nolint:errcheck
19
33
20
34
// based on https://github.com/golang/go/blob/f4e3ec3dbe3b8e04a058d266adf8e048bab563f2/src/os/file_windows.go#L389
0 commit comments