mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
AK: Rename Stream::{read,write} to Stream::{read_some,write_some}
Similar to POSIX read, the basic read and write functions of AK::Stream do not have a lower limit of how much data they read or write (apart from "none at all"). Rename the functions to "read some [data]" and "write some [data]" (with "data" being omitted, since everything here is reading and writing data) to make them sufficiently distinct from the functions that ensure to use the entire buffer (which should be the go-to function for most usages). No functional changes, just a lot of new FIXMEs.
This commit is contained in:
parent
1d5b45f7d9
commit
d5871f5717
109 changed files with 474 additions and 329 deletions
|
@ -18,7 +18,7 @@ ErrorOr<void> Stream::read_entire_buffer(Bytes buffer)
|
|||
if (is_eof())
|
||||
return Error::from_string_view_or_print_error_and_return_errno("Reached end-of-file before filling the entire buffer"sv, EIO);
|
||||
|
||||
auto result = read(buffer.slice(nread));
|
||||
auto result = read_some(buffer.slice(nread));
|
||||
if (result.is_error()) {
|
||||
if (result.error().is_errno() && result.error().code() == EINTR) {
|
||||
continue;
|
||||
|
@ -50,7 +50,7 @@ ErrorOr<ByteBuffer> Stream::read_until_eof_impl(size_t block_size, size_t expect
|
|||
buffer = TRY(data.get_bytes_for_writing(block_size));
|
||||
}
|
||||
|
||||
auto nread = TRY(read(buffer)).size();
|
||||
auto nread = TRY(read_some(buffer)).size();
|
||||
total_read += nread;
|
||||
buffer = buffer.slice(nread);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ ErrorOr<void> Stream::discard(size_t discarded_bytes)
|
|||
if (is_eof())
|
||||
return Error::from_string_view_or_print_error_and_return_errno("Reached end-of-file before reading all discarded bytes"sv, EIO);
|
||||
|
||||
auto slice = TRY(read(buffer.span().slice(0, min(discarded_bytes, continuous_read_size))));
|
||||
auto slice = TRY(read_some(buffer.span().slice(0, min(discarded_bytes, continuous_read_size))));
|
||||
discarded_bytes -= slice.size();
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ ErrorOr<void> Stream::write_entire_buffer(ReadonlyBytes buffer)
|
|||
{
|
||||
size_t nwritten = 0;
|
||||
while (nwritten < buffer.size()) {
|
||||
auto result = write(buffer.slice(nwritten));
|
||||
auto result = write_some(buffer.slice(nwritten));
|
||||
if (result.is_error()) {
|
||||
if (result.error().is_errno() && result.error().code() == EINTR) {
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue