diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-28 04:16:01 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-28 04:16:01 +0100 |
commit | c95228b128ea135ab0a931940725fab1ee335837 (patch) | |
tree | cd73d562f30b042559a2200458ab68510645a327 /Userland | |
parent | 031c62a21e4965afa38dc992cb6f7be0d214f224 (diff) | |
download | serenity-c95228b128ea135ab0a931940725fab1ee335837.zip |
Add support for removing directories.
It's really only supported in Ext2FS since SynthFS doesn't really want you
mucking around with its files. This is pretty neat though :^)
I ran into some trouble with HashMap while working on this but opted to work
around it and leave that for a separate investigation.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/.gitignore | 1 | ||||
-rw-r--r-- | Userland/Makefile | 5 | ||||
-rw-r--r-- | Userland/rmdir.cpp | 18 |
3 files changed, 24 insertions, 0 deletions
diff --git a/Userland/.gitignore b/Userland/.gitignore index 45e4d0fcc6..6ce961cd0c 100644 --- a/Userland/.gitignore +++ b/Userland/.gitignore @@ -26,3 +26,4 @@ guitest2 sysctl rm cp +rmdir diff --git a/Userland/Makefile b/Userland/Makefile index 4cca09a50d..e4bc3924e6 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -23,6 +23,7 @@ OBJS = \ guitest2.o \ sysctl.o \ cp.o \ + rmdir.o \ rm.o APPS = \ @@ -51,6 +52,7 @@ APPS = \ guitest2 \ sysctl \ cp \ + rmdir \ rm ARCH_FLAGS = @@ -149,6 +151,9 @@ cp: cp.o rm: rm.o $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a +rmdir: rmdir.o + $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Userland/rmdir.cpp b/Userland/rmdir.cpp new file mode 100644 index 0000000000..8d84f8cc67 --- /dev/null +++ b/Userland/rmdir.cpp @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <errno.h> +#include <unistd.h> + +int main(int argc, char** argv) +{ + if (argc != 2) { + fprintf(stderr, "usage: rmdir <path>\n"); + return 1; + } + int rc = rmdir(argv[1]); + if (rc < 0) { + perror("rmdir"); + return 1; + } + return 0; +} + |