summaryrefslogtreecommitdiff
path: root/libc/stdio/stdio.cpp
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2016-08-06 00:11:14 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-08-06 00:11:15 +0000
commit7e93d9c675a643e9b025eeb3c676cd10bc59d017 (patch)
treea094178ff6ae9af3f476c0480087a09a63a37000 /libc/stdio/stdio.cpp
parented9e6a41c92c9552be84ecc126e29b4604eee246 (diff)
parentd1f25a7eb171b490be59271e9ce619e236421aeb (diff)
Merge "Reimplement remove(3) without the lstat(2)."
Diffstat (limited to 'libc/stdio/stdio.cpp')
-rw-r--r--libc/stdio/stdio.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index 53b3faeb1..23a54de35 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -741,6 +741,12 @@ wint_t putwchar(wchar_t wc) {
return fputwc(wc, stdout);
}
+int remove(const char* path) {
+ if (unlink(path) != -1) return 0;
+ if (errno != EISDIR) return -1;
+ return rmdir(path);
+}
+
void rewind(FILE* fp) {
ScopedFileLock sfl(fp);
fseek(fp, 0, SEEK_SET);