OSDN Git Service

* dir.cc (rmdir): Care for misleading error messages
authorcorinna <corinna>
Mon, 22 May 2000 17:15:47 +0000 (17:15 +0000)
committercorinna <corinna>
Mon, 22 May 2000 17:15:47 +0000 (17:15 +0000)
        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.

winsup/cygwin/ChangeLog
winsup/cygwin/dir.cc
winsup/cygwin/syscalls.cc

index acf819b..01384d0 100644 (file)
@@ -1,3 +1,11 @@
+Mon May 16 23:39:00 2000  Corinna Vinschen <corinna@vinschen.de>
+
+       * 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.
+
 Sun May 21 20:51:44 2000  Christopher Faylor <cgf@cygnus.com>
 
        * dcrt0.cc (dll_crt0_1): Move uinfo_init call to before sigproc_init to
index 48187a2..d93f2e6 100644 (file)
@@ -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 ();
 
index c1ad04b..e6a5c06 100644 (file)
@@ -1231,7 +1231,8 @@ _rename (const char *oldpath, const char *newpath)
   if (!MoveFile (real_old.get_win32 (), real_new.get_win32 ()))
     res = -1;
 
-  if (res == 0 || GetLastError () != ERROR_ALREADY_EXISTS)
+  if (res == 0 || (GetLastError () != ERROR_ALREADY_EXISTS
+                   && GetLastError () != ERROR_FILE_EXISTS))
     goto done;
 
   if (os_being_run == winNT)