mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
LibCore: Add syscall wrapper for mkdir()
This commit is contained in:
parent
f69bd3bd46
commit
01c2756e9a
2 changed files with 16 additions and 0 deletions
|
@ -465,4 +465,19 @@ ErrorOr<void> symlink(StringView target, StringView link_path)
|
|||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<void> mkdir(StringView path, mode_t mode)
|
||||
{
|
||||
if (path.is_null())
|
||||
return Error::from_errno(EFAULT);
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_mkdir, path.characters_without_null_termination(), path.length(), mode);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("mkdir"sv, rc, {});
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::mkdir(path_string.characters(), mode) < 0)
|
||||
return Error::from_syscall("mkdir"sv, -errno);
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue