mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
LibCore: Add System::link()
This commit is contained in:
parent
bac4bdc5d2
commit
c44b9acac3
2 changed files with 19 additions and 0 deletions
|
@ -770,6 +770,24 @@ ErrorOr<bool> isatty(int fd)
|
|||
return rc == 1;
|
||||
}
|
||||
|
||||
ErrorOr<void> link(StringView old_path, StringView new_path)
|
||||
{
|
||||
#ifdef __serenity__
|
||||
Syscall::SC_link_params params {
|
||||
.old_path = { old_path.characters_without_null_termination(), old_path.length() },
|
||||
.new_path = { new_path.characters_without_null_termination(), new_path.length() },
|
||||
};
|
||||
int rc = syscall(SC_link, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("link", rc, {});
|
||||
#else
|
||||
String old_path_string = old_path;
|
||||
String new_path_string = new_path;
|
||||
if (::link(old_path_string.characters(), new_path_string.characters()) < 0)
|
||||
return Error::from_syscall("link"sv, -errno);
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<void> symlink(StringView target, StringView link_path)
|
||||
{
|
||||
#ifdef __serenity__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue