diff options
| author | Eli Zaretskii | 2017-08-14 19:17:22 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-08-14 19:17:22 +0300 |
| commit | 16f11be4b96fc37204dc950e64f78ed340cd70d8 (patch) | |
| tree | 5c72675b9dd76663b6fe93d65162952fc0ca0bb6 | |
| parent | 65899e5b0180284b87b1fa94c091b903056c6bfc (diff) | |
| download | emacs-16f11be4b96fc37204dc950e64f78ed340cd70d8.tar.gz emacs-16f11be4b96fc37204dc950e64f78ed340cd70d8.zip | |
Fix 'rename' on MS-Windows
* src/w32.c (sys_rename_replace): Use the FORCE argument only if
the primitive rename errors out with EEXIST.
| -rw-r--r-- | src/w32.c | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -4502,7 +4502,7 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) | |||
| 4502 | filename_to_utf16 (temp, temp_w); | 4502 | filename_to_utf16 (temp, temp_w); |
| 4503 | filename_to_utf16 (newname, newname_w); | 4503 | filename_to_utf16 (newname, newname_w); |
| 4504 | result = _wrename (temp_w, newname_w); | 4504 | result = _wrename (temp_w, newname_w); |
| 4505 | if (result < 0 && force) | 4505 | if (result < 0) |
| 4506 | { | 4506 | { |
| 4507 | DWORD w32err = GetLastError (); | 4507 | DWORD w32err = GetLastError (); |
| 4508 | 4508 | ||
| @@ -4520,7 +4520,7 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) | |||
| 4520 | && (attributes & FILE_ATTRIBUTE_DIRECTORY)) | 4520 | && (attributes & FILE_ATTRIBUTE_DIRECTORY)) |
| 4521 | errno = EXDEV; | 4521 | errno = EXDEV; |
| 4522 | } | 4522 | } |
| 4523 | else if (errno == EEXIST) | 4523 | else if (errno == EEXIST && force) |
| 4524 | { | 4524 | { |
| 4525 | if (_wchmod (newname_w, 0666) != 0) | 4525 | if (_wchmod (newname_w, 0666) != 0) |
| 4526 | return result; | 4526 | return result; |
| @@ -4546,7 +4546,7 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) | |||
| 4546 | filename_to_ansi (temp, temp_a); | 4546 | filename_to_ansi (temp, temp_a); |
| 4547 | filename_to_ansi (newname, newname_a); | 4547 | filename_to_ansi (newname, newname_a); |
| 4548 | result = rename (temp_a, newname_a); | 4548 | result = rename (temp_a, newname_a); |
| 4549 | if (result < 0 && force) | 4549 | if (result < 0) |
| 4550 | { | 4550 | { |
| 4551 | DWORD w32err = GetLastError (); | 4551 | DWORD w32err = GetLastError (); |
| 4552 | 4552 | ||
| @@ -4559,7 +4559,7 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) | |||
| 4559 | && (attributes & FILE_ATTRIBUTE_DIRECTORY)) | 4559 | && (attributes & FILE_ATTRIBUTE_DIRECTORY)) |
| 4560 | errno = EXDEV; | 4560 | errno = EXDEV; |
| 4561 | } | 4561 | } |
| 4562 | else if (errno == EEXIST) | 4562 | else if (errno == EEXIST && force) |
| 4563 | { | 4563 | { |
| 4564 | if (_chmod (newname_a, 0666) != 0) | 4564 | if (_chmod (newname_a, 0666) != 0) |
| 4565 | return result; | 4565 | return result; |