Commit 890c09ef authored by Kale Blankenship's avatar Kale Blankenship Committed by Brad Fitzpatrick

os: make IsExist report true on ERROR_DIR_NOT_EMPTY on Windows

Fixes #17164

Change-Id: I3e626d92293c1379e2922276f033fdee6f48dda3
Reviewed-on: https://go-review.googlesource.com/29753Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 60074b0f
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment