diff options
Diffstat (limited to 'compat')
| -rw-r--r-- | compat/mingw-posix.h | 8 | ||||
| -rw-r--r-- | compat/mingw.c | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/compat/mingw-posix.h b/compat/mingw-posix.h index 8dddfa818d..88e0cf9292 100644 --- a/compat/mingw-posix.h +++ b/compat/mingw-posix.h @@ -201,8 +201,12 @@ int uname(struct utsname *buf); * replacements of existing functions */ -int mingw_unlink(const char *pathname); -#define unlink mingw_unlink +int mingw_unlink(const char *pathname, int handle_in_use_error); +#ifdef MINGW_DONT_HANDLE_IN_USE_ERROR +# define unlink(path) mingw_unlink(path, 0) +#else +# define unlink(path) mingw_unlink(path, 1) +#endif int mingw_rmdir(const char *path); #define rmdir mingw_rmdir diff --git a/compat/mingw.c b/compat/mingw.c index 1d5b211b54..0e4b6a70a4 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -302,7 +302,7 @@ static wchar_t *normalize_ntpath(wchar_t *wbuf) return wbuf; } -int mingw_unlink(const char *pathname) +int mingw_unlink(const char *pathname, int handle_in_use_error) { int ret, tries = 0; wchar_t wpathname[MAX_PATH]; @@ -317,6 +317,9 @@ int mingw_unlink(const char *pathname) while ((ret = _wunlink(wpathname)) == -1 && tries < ARRAY_SIZE(delay)) { if (!is_file_in_use_error(GetLastError())) break; + if (!handle_in_use_error) + return ret; + /* * We assume that some other process had the source or * destination file open at the wrong moment and retry. |
