learned something new - remove is supposed to support directories on POSIX
authorRich Felker <dalias@aerifal.cx>
Tue, 29 Mar 2011 12:24:28 +0000 (08:24 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 29 Mar 2011 12:24:28 +0000 (08:24 -0400)
src/stdio/remove.c

index 9e1de7f239f698aac83307c1034863fb902c1501..fc12f7c10578d2f2f05bb2e7a6753dbe626e2ed7 100644 (file)
@@ -1,7 +1,9 @@
 #include <stdio.h>
+#include <errno.h>
 #include "syscall.h"
 
 int remove(const char *path)
 {
-       return syscall(SYS_unlink, path);
+       return (syscall(SYS_unlink, path) && errno == EISDIR)
+               ? syscall(SYS_rmdir, path) : 0;
 }