return ret;
}
+static int is_dir_empty(const char *path)
+{
+ struct strbuf buf = STRBUF_INIT;
+ WIN32_FIND_DATAA findbuf;
+ HANDLE handle;
+
+ strbuf_addf(&buf, "%s\\*", path);
+ handle = FindFirstFileA(buf.buf, &findbuf);
+ if (handle == INVALID_HANDLE_VALUE) {
+ strbuf_release(&buf);
+ return GetLastError() == ERROR_NO_MORE_FILES;
+ }
+
+ while (!strcmp(findbuf.cFileName, ".") ||
+ !strcmp(findbuf.cFileName, ".."))
+ if (!FindNextFile(handle, &findbuf)) {
+ strbuf_release(&buf);
+ return GetLastError() == ERROR_NO_MORE_FILES;
+ }
+ FindClose(handle);
+ strbuf_release(&buf);
+ return 0;
+}
+
#undef rmdir
int mingw_rmdir(const char *pathname)
{
while ((ret = rmdir(pathname)) == -1 && tries < ARRAY_SIZE(delay)) {
if (!is_file_in_use_error(GetLastError()))
break;
+ if (!is_dir_empty(pathname)) {
+ errno = ENOTEMPTY;
+ break;
+ }
/*
* We assume that some other process had the source or
* destination file open at the wrong moment and retry.