Re: [PATCH v4 5/5] mingw_rmdir: set errno=ENOTEMPTY when appropriate
- From
Erik Faye-Lund <kusmabite@gmail.com>
- Date
- Feb 7, 2011, 21:07 UTC
- Message-ID
- <AANLkTin6A-HVKvM9_5ggMezpM--tt1qUwSXF+CEaXg7J@mail.gmail.com>
- In-Reply-To
- <20110207205400.GF63976@book.hvoigt.net>
On Mon, Feb 7, 2011 at 9:54 PM, Heiko Voigt <hvoigt@hvoigt.net> wrote:
Show 7 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de> > > On Windows, EACCES overrules ENOTEMPTY when calling rmdir(). But if the > directory is busy, we only want to retry deleting the directory if it > is empty, so test specifically for that case and set ENOTEMPTY rather > than EACCES. >
I'm sorry, I don't quite understand. rmdir on Windows/MinGW fails with errno=ENOTEMPTY if a directory isn't empty: ---8<--- #include <errno.h> #include <stdlib.h> #include <stdio.h>
int main()
{
if (mkdir("foo") < 0 && errno != EEXIST) {
perror("mkdir");
exit(-1);
} if (!fopen("foo/bar", "w")) {
perror("fopen");
exit(-1);
} if (rmdir("foo") < 0)
perror("rmdir");
printf("errno: %d (expected %d)\n", errno, ENOTEMPTY);
}
---8<---
$ ./a.exe
rmdir: Directory not empty
errno: 41 (expected 41)