mirror of
https://github.com/golang/go
synced 2024-11-18 08:04:40 -07:00
os: make IsExist report true on ERROR_DIR_NOT_EMPTY on Windows
Fixes #17164 Change-Id: I3e626d92293c1379e2922276f033fdee6f48dda3 Reviewed-on: https://go-review.googlesource.com/29753 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
60074b0fd3
commit
890c09efb7
@ -9,6 +9,7 @@ import "syscall"
|
||||
func isExist(err error) bool {
|
||||
err = underlyingError(err)
|
||||
return err == syscall.ERROR_ALREADY_EXISTS ||
|
||||
err == syscall.ERROR_DIR_NOT_EMPTY ||
|
||||
err == syscall.ERROR_FILE_EXISTS || err == ErrExist
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,10 @@ func init() {
|
||||
isExistTest{err: &os.PathError{Err: syscall.ERROR_PATH_NOT_FOUND}, is: false, isnot: true},
|
||||
isExistTest{err: &os.LinkError{Err: syscall.ERROR_PATH_NOT_FOUND}, is: false, isnot: true},
|
||||
isExistTest{err: &os.SyscallError{Err: syscall.ERROR_PATH_NOT_FOUND}, is: false, isnot: true},
|
||||
|
||||
isExistTest{err: &os.PathError{Err: syscall.ERROR_DIR_NOT_EMPTY}, is: true, isnot: false},
|
||||
isExistTest{err: &os.LinkError{Err: syscall.ERROR_DIR_NOT_EMPTY}, is: true, isnot: false},
|
||||
isExistTest{err: &os.SyscallError{Err: syscall.ERROR_DIR_NOT_EMPTY}, is: true, isnot: false},
|
||||
)
|
||||
isPermissionTests = append(isPermissionTests,
|
||||
isPermissionTest{err: &os.PathError{Err: syscall.ERROR_ACCESS_DENIED}, want: true},
|
||||
|
@ -18,6 +18,7 @@ const (
|
||||
ERROR_INSUFFICIENT_BUFFER Errno = 122
|
||||
ERROR_MOD_NOT_FOUND Errno = 126
|
||||
ERROR_PROC_NOT_FOUND Errno = 127
|
||||
ERROR_DIR_NOT_EMPTY Errno = 145
|
||||
ERROR_ALREADY_EXISTS Errno = 183
|
||||
ERROR_ENVVAR_NOT_FOUND Errno = 203
|
||||
ERROR_MORE_DATA Errno = 234
|
||||
|
Loading…
Reference in New Issue
Block a user