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)
{
fclose(ftmp);
if (c == EOF && rename(tmp_file_name, input_file_name) < 0)
c = '.'; /* force an error */
if (c == EOF)
{
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);
}