summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2000-04-19 03:21:13 +0000
committerDJ Delorie <dj@redhat.com>2000-04-19 03:21:13 +0000
commitef6581f9ffada41bcede8df71b885f47716e8dad (patch)
tree9e512ae7912c01077a2dfc56a436bc829025cf78
parent7916b1efdac13489e3cd50aff6c9ee0863cd75ef (diff)
downloadcygnal-ef6581f9ffada41bcede8df71b885f47716e8dad.tar.gz
cygnal-ef6581f9ffada41bcede8df71b885f47716e8dad.tar.bz2
cygnal-ef6581f9ffada41bcede8df71b885f47716e8dad.zip
* syscalls.cc (_rename): Try MoveFile() at first before
MoveFileEx(..., MOVEFILE_REPLACE_EXISTING).
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/syscalls.cc52
2 files changed, 32 insertions, 25 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 80eb566dd..0de8344e0 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+Mon Apr 17 12:08:47 2000 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
+
+ * syscalls.cc (_rename): Try MoveFile() at first before
+ MoveFileEx(..., MOVEFILE_REPLACE_EXISTING).
+
Tue Apr 18 19:15:29 2000 Christopher Faylor <cgf@cygnus.com>
* dcrt0.cc (globify): Don't use \ quoting when apparently quoting a DOS
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 16f3b48d7..ca9777f79 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1200,43 +1200,45 @@ _rename (const char *oldpath, const char *newpath)
SetFileAttributesA (real_new.get_win32 (), newatts & ~ FILE_ATTRIBUTE_READONLY);
}
- /* First make sure we have the permissions */
- if (!MoveFileEx (real_old.get_win32 (), real_new.get_win32 (), MOVEFILE_REPLACE_EXISTING))
- {
- res = -1;
+ if (!MoveFile (real_old.get_win32 (), real_new.get_win32 ()))
+ res = -1;
- /* !!! fixme, check for windows version before trying this.. */
- if (GetLastError () == ERROR_CALL_NOT_IMPLEMENTED)
+ if (res == 0 || GetLastError () != ERROR_ALREADY_EXISTS)
+ goto done;
+
+ if (os_being_run == winNT)
+ {
+ if (MoveFileEx (real_old.get_win32 (), real_new.get_win32 (),
+ MOVEFILE_REPLACE_EXISTING))
+ res = 0;
+ }
+ else
+ {
+ syscall_printf ("try win95 hack");
+ for (;;)
{
- /* How sad, we must be on win95, try it the stupid way */
- syscall_printf ("try win95 hack");
- for (;;)
+ if (!DeleteFileA (real_new.get_win32 ()) &&
+ GetLastError () != ERROR_FILE_NOT_FOUND)
+ {
+ syscall_printf ("deleting %s to be paranoid",
+ real_new.get_win32 ());
+ break;
+ }
+ else
{
if (MoveFile (real_old.get_win32 (), real_new.get_win32 ()))
{
res = 0;
break;
}
-
- if (GetLastError () != ERROR_ALREADY_EXISTS)
- {
- syscall_printf ("%s already_exists", real_new.get_win32 ());
- break;
- }
-
- if (!DeleteFileA (real_new.get_win32 ()) &&
- GetLastError () != ERROR_FILE_NOT_FOUND)
- {
- syscall_printf ("deleting %s to be paranoid",
- real_new.get_win32 ());
- break;
- }
}
}
- if (res)
- __seterrno ();
}
+done:
+ if (res)
+ __seterrno ();
+
if (res == 0)
{
/* make the new file have the permissions of the old one */