diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 22 |
1 files changed, 16 insertions, 6 deletions
| @@ -4504,6 +4504,7 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) | |||
| 4504 | result = _wrename (temp_w, newname_w); | 4504 | result = _wrename (temp_w, newname_w); |
| 4505 | if (result < 0) | 4505 | if (result < 0) |
| 4506 | { | 4506 | { |
| 4507 | DWORD attributes; | ||
| 4507 | DWORD w32err = GetLastError (); | 4508 | DWORD w32err = GetLastError (); |
| 4508 | 4509 | ||
| 4509 | if (errno == EACCES | 4510 | if (errno == EACCES |
| @@ -4514,8 +4515,6 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) | |||
| 4514 | different storage device (ex. logical disk). It returns | 4515 | different storage device (ex. logical disk). It returns |
| 4515 | EACCES instead. So here we handle such situations and | 4516 | EACCES instead. So here we handle such situations and |
| 4516 | return EXDEV. */ | 4517 | return EXDEV. */ |
| 4517 | DWORD attributes; | ||
| 4518 | |||
| 4519 | if ((attributes = GetFileAttributesW (temp_w)) != -1 | 4518 | if ((attributes = GetFileAttributesW (temp_w)) != -1 |
| 4520 | && (attributes & FILE_ATTRIBUTE_DIRECTORY)) | 4519 | && (attributes & FILE_ATTRIBUTE_DIRECTORY)) |
| 4521 | errno = EXDEV; | 4520 | errno = EXDEV; |
| @@ -4524,7 +4523,13 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) | |||
| 4524 | { | 4523 | { |
| 4525 | if (_wchmod (newname_w, 0666) != 0) | 4524 | if (_wchmod (newname_w, 0666) != 0) |
| 4526 | return result; | 4525 | return result; |
| 4527 | if (_wunlink (newname_w) != 0) | 4526 | if ((attributes = GetFileAttributesW (newname_w)) != -1 |
| 4527 | && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) | ||
| 4528 | { | ||
| 4529 | if (_wrmdir (newname_w) != 0) | ||
| 4530 | return result; | ||
| 4531 | } | ||
| 4532 | else if (_wunlink (newname_w) != 0) | ||
| 4528 | return result; | 4533 | return result; |
| 4529 | result = _wrename (temp_w, newname_w); | 4534 | result = _wrename (temp_w, newname_w); |
| 4530 | } | 4535 | } |
| @@ -4548,13 +4553,12 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) | |||
| 4548 | result = rename (temp_a, newname_a); | 4553 | result = rename (temp_a, newname_a); |
| 4549 | if (result < 0) | 4554 | if (result < 0) |
| 4550 | { | 4555 | { |
| 4556 | DWORD attributes; | ||
| 4551 | DWORD w32err = GetLastError (); | 4557 | DWORD w32err = GetLastError (); |
| 4552 | 4558 | ||
| 4553 | if (errno == EACCES | 4559 | if (errno == EACCES |
| 4554 | && newname_dev != oldname_dev) | 4560 | && newname_dev != oldname_dev) |
| 4555 | { | 4561 | { |
| 4556 | DWORD attributes; | ||
| 4557 | |||
| 4558 | if ((attributes = GetFileAttributesA (temp_a)) != -1 | 4562 | if ((attributes = GetFileAttributesA (temp_a)) != -1 |
| 4559 | && (attributes & FILE_ATTRIBUTE_DIRECTORY)) | 4563 | && (attributes & FILE_ATTRIBUTE_DIRECTORY)) |
| 4560 | errno = EXDEV; | 4564 | errno = EXDEV; |
| @@ -4563,7 +4567,13 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) | |||
| 4563 | { | 4567 | { |
| 4564 | if (_chmod (newname_a, 0666) != 0) | 4568 | if (_chmod (newname_a, 0666) != 0) |
| 4565 | return result; | 4569 | return result; |
| 4566 | if (_unlink (newname_a) != 0) | 4570 | if ((attributes = GetFileAttributesA (newname_a)) != -1 |
| 4571 | && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) | ||
| 4572 | { | ||
| 4573 | if (_rmdir (newname_a) != 0) | ||
| 4574 | return result; | ||
| 4575 | } | ||
| 4576 | else if (_unlink (newname_a) != 0) | ||
| 4567 | return result; | 4577 | return result; |
| 4568 | result = rename (temp_a, newname_a); | 4578 | result = rename (temp_a, newname_a); |
| 4569 | } | 4579 | } |