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 9e1de7f..fc12f7c 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;
 }