mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibCore: Add syscall wrapper for utime()
This commit is contained in:
parent
186de9fe4d
commit
bd8f10db80
2 changed files with 20 additions and 0 deletions
|
@ -537,4 +537,23 @@ ErrorOr<void> rename(StringView old_path, StringView new_path)
|
|||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<void> utime(StringView path, Optional<struct utimbuf> maybe_buf)
|
||||
{
|
||||
if (path.is_null())
|
||||
return Error::from_errno(EFAULT);
|
||||
|
||||
struct utimbuf* buf = nullptr;
|
||||
if (maybe_buf.has_value())
|
||||
buf = &maybe_buf.value();
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_utime, path.characters_without_null_termination(), path.length(), buf);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("utime"sv, rc, {});
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::utime(path.characters(), buf) < 0)
|
||||
return Error::from_syscall("utime"sv, -errno);
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue