diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2000-05-22 17:15:47 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2000-05-22 17:15:47 +0000 |
commit | 689221682269bf5c40567d15d28bfb73369253e7 (patch) | |
tree | a13f3a2b3f90ea1071d94f8920dd3f5727272ee0 /winsup/cygwin/dir.cc | |
parent | 7054be8b55c2f06303b0b9111dabba0ca8abe999 (diff) | |
download | newlib-689221682269bf5c40567d15d28bfb73369253e7.zip newlib-689221682269bf5c40567d15d28bfb73369253e7.tar.gz newlib-689221682269bf5c40567d15d28bfb73369253e7.tar.bz2 |
* dir.cc (rmdir): Care for misleading error messages
when trying to remove a directory on a samba share.
Eliminate superfluous else branch.
* syscalls.cc (_rename): Additional check for ERROR_FILE_EXISTS
if MoveFile fails.
Diffstat (limited to 'winsup/cygwin/dir.cc')
-rw-r--r-- | winsup/cygwin/dir.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index 48187a2..d93f2e6 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -319,18 +319,27 @@ rmdir (const char *dir) } if (RemoveDirectoryA (real_dir.get_win32 ())) - res = 0; - else if (os_being_run != winNT && GetLastError() == ERROR_ACCESS_DENIED) { - /* Under Windows 95 & 98, ERROR_ACCESS_DENIED is returned - if you try to remove a file or a non-empty directory. */ + /* RemoveDirectory on a samba drive doesn't return an error if the + directory can't be removed because it's not empty. Checking for + existence afterwards keeps us informed about success. */ + if (GetFileAttributesA (real_dir.get_win32 ()) != (DWORD) -1) + set_errno (ENOTEMPTY); + else + res = 0; + } + else if (GetLastError() == ERROR_ACCESS_DENIED) + { + /* Under Windows 9X or on a samba share, ERROR_ACCESS_DENIED is + returned if you try to remove a file. On 9X the same error is + returned if you try to remove a non-empty directory. */ if (GetFileAttributes (real_dir.get_win32()) != FILE_ATTRIBUTE_DIRECTORY) set_errno (ENOTDIR); - else + else if (os_being_run != winNT) set_errno (ENOTEMPTY); + else + __seterrno (); } - else if (GetLastError () == ERROR_DIRECTORY) - set_errno (ENOTDIR); else __seterrno (); |