From 694cda6e40c03c3a402ec2f6e32f37ec5463425c Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 14 Dec 2023 10:58:50 +0200 Subject: [PATCH] LibC: Implement remove for stdio --- libc/stdio.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libc/stdio.cpp b/libc/stdio.cpp index 63b00d93fd..2ce91849ea 100644 --- a/libc/stdio.cpp +++ b/libc/stdio.cpp @@ -422,8 +422,15 @@ int puts(const char* string) return 0; } -// TODO -int remove(const char*); +int remove(const char* path) +{ + struct stat st; + if (stat(path, &st) == -1) + return -1; + if (S_ISDIR(st.st_mode)) + return rmdir(path); + return unlink(path); +} // TODO int rename(const char*, const char*);