mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +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
|
@ -181,7 +181,7 @@ ErrorOr<bool> DeflateDecompressor::UncompressedBlock::try_read_more()
|
|||
|
||||
Array<u8, 4096> temporary_buffer;
|
||||
auto readable_bytes = temporary_buffer.span().trim(min(m_bytes_remaining, m_decompressor.m_output_buffer.empty_space()));
|
||||
auto read_bytes = TRY(m_decompressor.m_input_stream->read(readable_bytes));
|
||||
auto read_bytes = TRY(m_decompressor.m_input_stream->read_some(readable_bytes));
|
||||
auto written_bytes = m_decompressor.m_output_buffer.write(read_bytes);
|
||||
VERIFY(read_bytes.size() == written_bytes);
|
||||
|
||||
|
@ -209,7 +209,7 @@ DeflateDecompressor::~DeflateDecompressor()
|
|||
m_uncompressed_block.~UncompressedBlock();
|
||||
}
|
||||
|
||||
ErrorOr<Bytes> DeflateDecompressor::read(Bytes bytes)
|
||||
ErrorOr<Bytes> DeflateDecompressor::read_some(Bytes bytes)
|
||||
{
|
||||
size_t total_read = 0;
|
||||
while (total_read < bytes.size()) {
|
||||
|
@ -225,9 +225,10 @@ ErrorOr<Bytes> DeflateDecompressor::read(Bytes bytes)
|
|||
if (block_type == 0b00) {
|
||||
m_input_stream->align_to_byte_boundary();
|
||||
|
||||
// FIXME: This should read the entire span.
|
||||
LittleEndian<u16> length, negated_length;
|
||||
TRY(m_input_stream->read(length.bytes()));
|
||||
TRY(m_input_stream->read(negated_length.bytes()));
|
||||
TRY(m_input_stream->read_some(length.bytes()));
|
||||
TRY(m_input_stream->read_some(negated_length.bytes()));
|
||||
|
||||
if ((length ^ 0xffff) != negated_length)
|
||||
return Error::from_string_literal("Calculated negated length does not equal stored negated length");
|
||||
|
@ -301,7 +302,7 @@ ErrorOr<Bytes> DeflateDecompressor::read(Bytes bytes)
|
|||
|
||||
bool DeflateDecompressor::is_eof() const { return m_state == State::Idle && m_read_final_bock; }
|
||||
|
||||
ErrorOr<size_t> DeflateDecompressor::write(ReadonlyBytes)
|
||||
ErrorOr<size_t> DeflateDecompressor::write_some(ReadonlyBytes)
|
||||
{
|
||||
return Error::from_errno(EBADF);
|
||||
}
|
||||
|
@ -323,7 +324,7 @@ ErrorOr<ByteBuffer> DeflateDecompressor::decompress_all(ReadonlyBytes bytes)
|
|||
|
||||
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
||||
while (!deflate_stream->is_eof()) {
|
||||
auto const slice = TRY(deflate_stream->read(buffer));
|
||||
auto const slice = TRY(deflate_stream->read_some(buffer));
|
||||
TRY(output_stream.write_entire_buffer(slice));
|
||||
}
|
||||
|
||||
|
@ -468,12 +469,12 @@ DeflateCompressor::~DeflateCompressor()
|
|||
VERIFY(m_finished);
|
||||
}
|
||||
|
||||
ErrorOr<Bytes> DeflateCompressor::read(Bytes)
|
||||
ErrorOr<Bytes> DeflateCompressor::read_some(Bytes)
|
||||
{
|
||||
return Error::from_errno(EBADF);
|
||||
}
|
||||
|
||||
ErrorOr<size_t> DeflateCompressor::write(ReadonlyBytes bytes)
|
||||
ErrorOr<size_t> DeflateCompressor::write_some(ReadonlyBytes bytes)
|
||||
{
|
||||
VERIFY(!m_finished);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue