mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
LibCore: Impliment ErrorOr wrapper for chdir
This commit is contained in:
parent
571d090609
commit
eacbbca4c4
2 changed files with 16 additions and 0 deletions
|
@ -592,6 +592,21 @@ ErrorOr<void> mkdir(StringView path, mode_t mode)
|
|||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<void> chdir(StringView path)
|
||||
{
|
||||
if (path.is_null())
|
||||
return Error::from_errno(EFAULT);
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_chdir, path.characters_without_null_termination(), path.length());
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chdir"sv, rc, {});
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::chdir(path_string.characters()) < 0)
|
||||
return Error::from_syscall("chdir"sv, -errno);
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<pid_t> fork()
|
||||
{
|
||||
pid_t pid = ::fork();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue