diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2016-08-06 00:11:14 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-08-06 00:11:15 +0000 |
commit | 7e93d9c675a643e9b025eeb3c676cd10bc59d017 (patch) | |
tree | a094178ff6ae9af3f476c0480087a09a63a37000 /libc/stdio/stdio.cpp | |
parent | ed9e6a41c92c9552be84ecc126e29b4604eee246 (diff) | |
parent | d1f25a7eb171b490be59271e9ce619e236421aeb (diff) |
Merge "Reimplement remove(3) without the lstat(2)."
Diffstat (limited to 'libc/stdio/stdio.cpp')
-rw-r--r-- | libc/stdio/stdio.cpp | 6 |
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); |