os.Lstat can return ENOTDIR as well.
R=golang-dev, r, alex.brainman
CC=golang-dev, rsc
https://golang.org/cl/
4984051
// both errors will be ENOTDIR, so it's okay to
// use the error from unlink.
// For windows syscall.ENOTDIR is set
- // to syscall.ERROR_DIRECTORY, hopefully it should
+ // to syscall.ERROR_PATH_NOT_FOUND, hopefully it should
// do the trick.
if e1 != syscall.ENOTDIR {
e = e1
if e == nil {
return r, nil
}
- // Imitating Unix behavior by replacing syscall.ERROR_PATH_NOT_FOUND with
- // os.ENOTDIR. Not sure if we should go into that.
- if e2, ok := e.(*PathError); ok {
- if e3, ok := e2.Error.(Errno); ok {
- if e3 == Errno(syscall.ERROR_PATH_NOT_FOUND) {
- return nil, &PathError{"open", name, ENOTDIR}
- }
- }
- }
return nil, e
}
// Otherwise, is this a directory we need to recurse into?
dir, serr := Lstat(path)
if serr != nil {
- if serr, ok := serr.(*PathError); ok && serr.Error == ENOENT {
+ if serr, ok := serr.(*PathError); ok && (serr.Error == ENOENT || serr.Error == ENOTDIR) {
return nil
}
return serr
# These are go errors that will be mapped directly to windows errors
goerrors='
ENOENT:ERROR_FILE_NOT_FOUND
-ENOTDIR:ERROR_DIRECTORY
+ENOTDIR:ERROR_PATH_NOT_FOUND
'
# Pull out just the error names for later.
// Go names for Windows errors.
const (
ENOENT = ERROR_FILE_NOT_FOUND
- ENOTDIR = ERROR_DIRECTORY
+ ENOTDIR = ERROR_PATH_NOT_FOUND
)
// Windows reserves errors >= 1<<29 for application use.