Workaround for windoze bug.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14459 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-09-16 14:25:06 +00:00
parent 8453f2c2f8
commit a9a2990b67
2 changed files with 17 additions and 8 deletions

View file

@ -6,6 +6,8 @@
actually need it. Account 'Number' methods and dictionary keys changed
to be account 'ID' instead ... in accordance with MacOS-X usage.
Documented the class.
* Source/NSData.m: ([-writeToFile:atomically:]) implement workaround
for bug in windoze implementation of rename()
2002-09-15 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -911,7 +911,13 @@ failure:
IF_NO_GC(TEST_AUTORELEASE(att));
}
#if defined(__NEW__MINGW__)
#if defined(__MINGW__)
/*
* The windoze implementation of the POSIX rename() function is buggy
* and doesn't work if the destination file already exists ... so we
* try to use a windoze specific function instead.
*/
#if 0
if (ReplaceFile(theRealPath, thePath, 0,
REPLACEFILE_IGNORE_MERGE_ERRORS, 0, 0) != 0)
{
@ -922,16 +928,17 @@ failure:
c = -1;
}
#else
c = rename(thePath, theRealPath);
#if defined(__MINGW__)
if (c != 0)
if (MoveFileEx(thePath, theRealPath, MOVEFILE_REPLACE_EXISTING) != 0)
{
NSLog(@"Rename ('%s' to '%s') failed - %s trying delete first.",
thePath, theRealPath, GSLastErrorStr(errno));
DeleteFile(theRealPath); // Non-atomic!
c = rename(thePath, theRealPath);
c = 0;
}
else
{
c = -1;
}
#endif
#else
c = rename(thePath, theRealPath);
#endif
if (c != 0) /* Many things could go wrong, I guess. */
{