summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibCore/System.cpp15
-rw-r--r--Userland/Libraries/LibCore/System.h2
2 files changed, 16 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp
index e19b111b54..bcac0946b4 100644
--- a/Userland/Libraries/LibCore/System.cpp
+++ b/Userland/Libraries/LibCore/System.cpp
@@ -766,6 +766,21 @@ ErrorOr<void> chdir(StringView path)
#endif
}
+ErrorOr<void> rmdir(StringView path)
+{
+ if (path.is_null())
+ return Error::from_errno(EFAULT);
+#ifdef __serenity__
+ int rc = syscall(SC_rmdir, path.characters_without_null_termination(), path.length());
+ HANDLE_SYSCALL_RETURN_VALUE("rmdir"sv, rc, {});
+#else
+ String path_string = path;
+ if (::rmdir(path_string.characters()) < 0)
+ return Error::from_syscall("rmdir"sv, -errno);
+ return {};
+#endif
+}
+
ErrorOr<pid_t> fork()
{
pid_t pid = ::fork();
diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h
index cf581ec08e..9dcc50877c 100644
--- a/Userland/Libraries/LibCore/System.h
+++ b/Userland/Libraries/LibCore/System.h
@@ -111,6 +111,7 @@ ErrorOr<bool> isatty(int fd);
ErrorOr<void> symlink(StringView target, StringView link_path);
ErrorOr<void> mkdir(StringView path, mode_t);
ErrorOr<void> chdir(StringView path);
+ErrorOr<void> rmdir(StringView path);
ErrorOr<pid_t> fork();
ErrorOr<int> mkstemp(Span<char> pattern);
ErrorOr<void> fchmod(int fd, mode_t mode);
@@ -142,5 +143,4 @@ ErrorOr<void> socketpair(int domain, int type, int protocol, int sv[2]);
ErrorOr<Vector<gid_t>> getgroups();
ErrorOr<void> mknod(StringView pathname, mode_t mode, dev_t dev);
ErrorOr<void> mkfifo(StringView pathname, mode_t mode);
-
}