Skip to content

Commit

Permalink
mingw: Try to delete target directory first.
Browse files Browse the repository at this point in the history
When the rename function tries to move a directory it fails if the target
directory exists. It should check if it can delete the (possibly empty)
target directory and then try again to move the directory.

Helped-by: Johannes Schindelin <[email protected]>
Signed-off-by: 마누엘 <[email protected]>
  • Loading branch information
nalla authored and dscho committed Mar 20, 2015
1 parent c31754f commit 1f6151d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,12 @@ int mingw_rename(const char *pold, const char *pnew)
if (gle == ERROR_ACCESS_DENIED &&
(attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
errno = EISDIR;
DWORD attrsold = GetFileAttributesW(wpold);
if (attrsold == INVALID_FILE_ATTRIBUTES ||
!(attrsold & FILE_ATTRIBUTE_DIRECTORY))
errno = EISDIR;
else if (!_wrmdir(wpnew))
goto repeat;
return -1;
}
if ((attrs & FILE_ATTRIBUTE_READONLY) &&
Expand Down

0 comments on commit 1f6151d

Please sign in to comment.