* syscalls.cc (_rename): Try MoveFile() at first before
MoveFileEx(..., MOVEFILE_REPLACE_EXISTING).
This commit is contained in:
parent
7916b1efda
commit
ef6581f9ff
|
@ -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>
|
Tue Apr 18 19:15:29 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* dcrt0.cc (globify): Don't use \ quoting when apparently quoting a DOS
|
* dcrt0.cc (globify): Don't use \ quoting when apparently quoting a DOS
|
||||||
|
|
|
@ -1200,43 +1200,45 @@ _rename (const char *oldpath, const char *newpath)
|
||||||
SetFileAttributesA (real_new.get_win32 (), newatts & ~ FILE_ATTRIBUTE_READONLY);
|
SetFileAttributesA (real_new.get_win32 (), newatts & ~ FILE_ATTRIBUTE_READONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First make sure we have the permissions */
|
if (!MoveFile (real_old.get_win32 (), real_new.get_win32 ()))
|
||||||
if (!MoveFileEx (real_old.get_win32 (), real_new.get_win32 (), MOVEFILE_REPLACE_EXISTING))
|
res = -1;
|
||||||
{
|
|
||||||
res = -1;
|
|
||||||
|
|
||||||
/* !!! fixme, check for windows version before trying this.. */
|
if (res == 0 || GetLastError () != ERROR_ALREADY_EXISTS)
|
||||||
if (GetLastError () == ERROR_CALL_NOT_IMPLEMENTED)
|
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 */
|
if (!DeleteFileA (real_new.get_win32 ()) &&
|
||||||
syscall_printf ("try win95 hack");
|
GetLastError () != ERROR_FILE_NOT_FOUND)
|
||||||
for (;;)
|
{
|
||||||
|
syscall_printf ("deleting %s to be paranoid",
|
||||||
|
real_new.get_win32 ());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (MoveFile (real_old.get_win32 (), real_new.get_win32 ()))
|
if (MoveFile (real_old.get_win32 (), real_new.get_win32 ()))
|
||||||
{
|
{
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
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)
|
if (res == 0)
|
||||||
{
|
{
|
||||||
/* make the new file have the permissions of the old one */
|
/* make the new file have the permissions of the old one */
|
||||||
|
|
Loading…
Reference in New Issue