(sys_rename): On some network drives, rename fails with
authorRichard M. Stallman <rms@gnu.org>
Tue, 16 Jun 1998 04:33:08 +0000 (04:33 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 16 Jun 1998 04:33:08 +0000 (04:33 +0000)
EACCES instead of EEXIST if target already exists.

src/w32.c

index da7d29b..f35ebc6 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -1558,12 +1558,12 @@ sys_rename (const char * oldname, const char * newname)
        {
          /* Force temp name to require a manufactured 8.3 alias - this
             seems to make the second rename work properly.  */
-         sprintf (p, ".%s.%u", o, i);
+         sprintf (p, "_.%s.%u", o, i);
          i++;
          result = rename (oldname, temp);
        }
       /* This loop must surely terminate!  */
-      while (result < 0 && errno == EEXIST);
+      while (result < 0 && (errno == EEXIST || errno == EACCES));
       if (result < 0)
        return -1;
     }
@@ -1583,7 +1583,7 @@ sys_rename (const char * oldname, const char * newname)
   result = rename (temp, newname);
 
   if (result < 0
-      && errno == EEXIST
+      && (errno == EEXIST || errno == EACCES)
       && _chmod (newname, 0666) == 0
       && _unlink (newname) == 0)
     result = rename (temp, newname);