diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-02-24 22:38:01 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-13 15:16:20 +0000 |
commit | d5871f5717579fab3c093537c44e3cd467560cdd (patch) | |
tree | 9e7e118ae5b7642f0168c5302ee74e9e483ae91c /Userland/Libraries/LibArchive | |
parent | 1d5b45f7d938b15db9da9b12dc4d8b373abd6c7c (diff) | |
download | serenity-d5871f5717579fab3c093537c44e3cd467560cdd.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibArchive')
-rw-r--r-- | Userland/Libraries/LibArchive/TarStream.cpp | 11 | ||||
-rw-r--r-- | Userland/Libraries/LibArchive/TarStream.h | 4 |
2 files changed, 8 insertions, 7 deletions
diff --git a/Userland/Libraries/LibArchive/TarStream.cpp b/Userland/Libraries/LibArchive/TarStream.cpp index f2c7725cef..1515185f2f 100644 --- a/Userland/Libraries/LibArchive/TarStream.cpp +++ b/Userland/Libraries/LibArchive/TarStream.cpp @@ -18,7 +18,7 @@ TarFileStream::TarFileStream(TarInputStream& tar_stream) { } -ErrorOr<Bytes> TarFileStream::read(Bytes bytes) +ErrorOr<Bytes> TarFileStream::read_some(Bytes bytes) { // Verify that the stream has not advanced. VERIFY(m_tar_stream.m_generation == m_generation); @@ -27,7 +27,7 @@ ErrorOr<Bytes> TarFileStream::read(Bytes bytes) auto to_read = min(bytes.size(), header_size - m_tar_stream.m_file_offset); - auto slice = TRY(m_tar_stream.m_stream->read(bytes.trim(to_read))); + auto slice = TRY(m_tar_stream.m_stream->read_some(bytes.trim(to_read))); m_tar_stream.m_file_offset += slice.size(); return slice; @@ -47,7 +47,7 @@ bool TarFileStream::is_eof() const || m_tar_stream.m_file_offset >= header_size; } -ErrorOr<size_t> TarFileStream::write(ReadonlyBytes) +ErrorOr<size_t> TarFileStream::write_some(ReadonlyBytes) { return Error::from_errno(EBADF); } @@ -92,7 +92,8 @@ ErrorOr<void> TarInputStream::load_next_header() { size_t number_of_consecutive_zero_blocks = 0; while (true) { - auto header_span = TRY(m_stream->read(Bytes(&m_header, sizeof(m_header)))); + // FIXME: This should read the entire span. + auto header_span = TRY(m_stream->read_some(Bytes(&m_header, sizeof(m_header)))); if (header_span.size() != sizeof(m_header)) return Error::from_string_literal("Failed to read the entire header"); @@ -175,7 +176,7 @@ ErrorOr<void> TarOutputStream::add_file(StringView path, mode_t mode, ReadonlyBy TRY(m_stream->write_entire_buffer(ReadonlyBytes { &padding, block_size - sizeof(header) })); size_t n_written = 0; while (n_written < bytes.size()) { - n_written += MUST(m_stream->write(bytes.slice(n_written, min(bytes.size() - n_written, block_size)))); + n_written += MUST(m_stream->write_some(bytes.slice(n_written, min(bytes.size() - n_written, block_size)))); } TRY(m_stream->write_entire_buffer(ReadonlyBytes { &padding, block_size - (n_written % block_size) })); return {}; diff --git a/Userland/Libraries/LibArchive/TarStream.h b/Userland/Libraries/LibArchive/TarStream.h index 61e104b35b..45cc1eb111 100644 --- a/Userland/Libraries/LibArchive/TarStream.h +++ b/Userland/Libraries/LibArchive/TarStream.h @@ -18,8 +18,8 @@ class TarInputStream; class TarFileStream : public Stream { public: - virtual ErrorOr<Bytes> read(Bytes) override; - virtual ErrorOr<size_t> write(ReadonlyBytes) override; + virtual ErrorOr<Bytes> read_some(Bytes) override; + virtual ErrorOr<size_t> write_some(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override { return true; }; virtual void close() override {}; |