1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

LibCore: Add rmdir system call wrapper

This commit is contained in:
Lenny Maiorani 2022-02-12 18:35:38 -07:00 committed by Andreas Kling
parent 1dd70a6f49
commit b455363ce7
2 changed files with 16 additions and 1 deletions

View file

@ -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();