瀏覽代碼

LibC: Make remove() propagate non-EISDIR unlink() errors

Regressed in 16105091ba5cb8e9d81eabcb499e70b1907ffc08.
Andreas Kling 3 年之前
父節點
當前提交
c93687c15e
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      Userland/Libraries/LibC/stdio.cpp

+ 5 - 2
Userland/Libraries/LibC/stdio.cpp

@@ -1236,8 +1236,11 @@ int pclose(FILE* stream)
 
 int remove(const char* pathname)
 {
-    if (unlink(pathname) < 0 && errno == EISDIR)
-        return rmdir(pathname);
+    if (unlink(pathname) < 0) {
+        if (errno == EISDIR)
+            return rmdir(pathname);
+        return -1;
+    }
     return 0;
 }