mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibCore: Add syscall wrappers for read() and write()
This commit is contained in:
parent
221a32577e
commit
16356ca478
Notes:
sideshowbarker
2024-07-18 00:48:22 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/16356ca4784
2 changed files with 18 additions and 0 deletions
|
@ -148,4 +148,20 @@ ErrorOr<struct stat> stat(StringView path)
|
|||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<ssize_t> read(int fd, void* buffer, size_t buffer_size)
|
||||
{
|
||||
ssize_t rc = ::read(fd, buffer, buffer_size);
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("read"sv, -errno);
|
||||
return rc;
|
||||
}
|
||||
|
||||
ErrorOr<ssize_t> write(int fd, void const* data, size_t data_size)
|
||||
{
|
||||
ssize_t rc = ::write(fd, data, data_size);
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("write"sv, -errno);
|
||||
return rc;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,5 +26,7 @@ ErrorOr<int> open(StringView path, int options, ...);
|
|||
ErrorOr<void> close(int fd);
|
||||
ErrorOr<void> ftruncate(int fd, off_t length);
|
||||
ErrorOr<struct stat> stat(StringView path);
|
||||
ErrorOr<ssize_t> read(int fd, void* buffer, size_t buffer_size);
|
||||
ErrorOr<ssize_t> write(int fd, void const* data, size_t data_size);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue