Преглед на файлове

learned something new - remove is supposed to support directories on POSIX

Rich Felker преди 14 години
родител
ревизия
0b240ccf52
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      src/stdio/remove.c

+ 3 - 1
src/stdio/remove.c

@@ -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;
 }