On Saturday, 10 December 2016 at 03:36:11 UTC, Adam D. Ruppe
wrote:
On Saturday, 10 December 2016 at 03:29:18 UTC, unDEFER wrote:
But it works under Linux
That's just because the underlying C function handles the case.
But the D function makes no promises about that:
std.file.remove's documentation says "removes the file",
leaving what it does to directories undefined.
Interestingly, the Linux kernel *does* make the distinction:
the C remove function on Linux does a test then calls unlink or
rmdir based on if it is a directory or not. But it didn't
always do that.
But what you have is undefined behavior - the function is only
guaranteed to work on files, and does not specify if it will
work or be an error on directories.
Thank you, but I think in this case D must use unlink for
implementation remove.