1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibCore+cat: Switch Core::System::read/write to take a Span of bytes

In the spirit of the Core::System name space having "modern" facades
for classically C functions / Kernel interfaces, it seems appropriate
that we should take Span's of data instead of raw pointer + length
arguments.
This commit is contained in:
Brian Gianforcaro 2021-11-27 13:02:33 -08:00 committed by Andreas Kling
parent eb896aa33e
commit fcc00c9a27
3 changed files with 14 additions and 11 deletions

View file

@ -157,17 +157,17 @@ ErrorOr<struct stat> stat(StringView path)
#endif
}
ErrorOr<ssize_t> read(int fd, void* buffer, size_t buffer_size)
ErrorOr<ssize_t> read(int fd, Bytes buffer)
{
ssize_t rc = ::read(fd, buffer, buffer_size);
ssize_t rc = ::read(fd, buffer.data(), 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)
ErrorOr<ssize_t> write(int fd, ReadonlyBytes buffer)
{
ssize_t rc = ::write(fd, data, data_size);
ssize_t rc = ::write(fd, buffer.data(), buffer.size());
if (rc < 0)
return Error::from_syscall("write"sv, -errno);
return rc;