mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibCore: Add syscall wrapper for mkdir()
This commit is contained in:
parent
f69bd3bd46
commit
01c2756e9a
Notes:
sideshowbarker
2024-07-17 22:41:38 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/01c2756e9a6
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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,5 +63,6 @@ ErrorOr<void> setgid(gid_t);
|
|||
ErrorOr<void> setegid(gid_t);
|
||||
ErrorOr<bool> isatty(int fd);
|
||||
ErrorOr<void> symlink(StringView target, StringView link_path);
|
||||
ErrorOr<void> mkdir(StringView path, mode_t);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue