Windows rename() needs an unlink() first (reported by Steven
Edwards).
This commit is contained in:
parent
8451240526
commit
e97fb4b0d6
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue