aboutsummaryrefslogtreecommitdiff
path: root/src/os/stat_windows.go
diff options
context:
space:
mode:
authorConstantin Konstantinidis <constantinkonstantinidis@gmail.com>2019-07-15 06:32:40 +0200
committerAlex Brainman <alex.brainman@gmail.com>2019-08-29 09:53:56 +0000
commit5cf5a6fc5eca5e05ab7cd189a19196e73c5408c4 (patch)
tree5dd002456536f92bbe4dcde33b6bd94226bff809 /src/os/stat_windows.go
parentcb325fed43009d5197caa5b1afa859cbc0e39355 (diff)
downloadgo-5cf5a6fc5eca5e05ab7cd189a19196e73c5408c4.tar.xz
os: return an error when the argument of Mkdir on Windows is os.DevNull
Test added. Fixes #24556 Change-Id: I4d1cd4513142edeea1a983fbfde46c2fccecab2a Reviewed-on: https://go-review.googlesource.com/c/go/+/186139 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/os/stat_windows.go')
-rw-r--r--src/os/stat_windows.go22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/os/stat_windows.go b/src/os/stat_windows.go
index fd22ef21ab..3e0e0a59ed 100644
--- a/src/os/stat_windows.go
+++ b/src/os/stat_windows.go
@@ -10,24 +10,6 @@ import (
"unsafe"
)
-// isNulName reports whether name is NUL file name.
-// For example, it returns true for both "NUL" and "nul".
-func isNulName(name string) bool {
- if len(name) != 3 {
- return false
- }
- if name[0] != 'n' && name[0] != 'N' {
- return false
- }
- if name[1] != 'u' && name[1] != 'U' {
- return false
- }
- if name[2] != 'l' && name[2] != 'L' {
- return false
- }
- return true
-}
-
// Stat returns the FileInfo structure describing file.
// If there is an error, it will be of type *PathError.
func (file *File) Stat() (FileInfo, error) {
@@ -39,7 +21,7 @@ func (file *File) Stat() (FileInfo, error) {
// I don't know any better way to do that for directory
return Stat(file.dirinfo.path)
}
- if isNulName(file.name) {
+ if isWindowsNulName(file.name) {
return &devNullStat, nil
}
@@ -65,7 +47,7 @@ func stat(funcname, name string, createFileAttrs uint32) (FileInfo, error) {
if len(name) == 0 {
return nil, &PathError{funcname, name, syscall.Errno(syscall.ERROR_PATH_NOT_FOUND)}
}
- if isNulName(name) {
+ if isWindowsNulName(name) {
return &devNullStat, nil
}
namep, err := syscall.UTF16PtrFromString(fixLongPath(name))