1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 03:07:35 +00:00

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.
This commit is contained in:
Andreas Kling 2019-01-28 04:16:01 +01:00
parent 031c62a21e
commit c95228b128
19 changed files with 185 additions and 40 deletions

1
Userland/.gitignore vendored
View file

@ -26,3 +26,4 @@ guitest2
sysctl
rm
cp
rmdir

View file

@ -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 $<

18
Userland/rmdir.cpp Normal file
View file

@ -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;
}