Windows rename() needs an unlink() first (reported by Steven

Edwards).
This commit is contained in:
Alexandre Julliard 2004-01-18 23:32:56 +00:00
parent 8451240526
commit e97fb4b0d6
1 changed files with 12 additions and 2 deletions

View File

@ -183,8 +183,18 @@ int process_resources(const char* input_file_name, const char* specific_file_nam
if (inserting) if (inserting)
{ {
fclose(ftmp); fclose(ftmp);
if (c == EOF && rename(tmp_file_name, input_file_name) < 0) if (c == EOF)
c = '.'; /* force an error */ {
if (rename(tmp_file_name, input_file_name) < 0)
{
/* try unlinking first, Windows rename is brain-damaged */
if (unlink(input_file_name) < 0 || rename(tmp_file_name, input_file_name) < 0)
{
unlink(tmp_file_name);
return 0;
}
}
}
else unlink(tmp_file_name); else unlink(tmp_file_name);
} }