diff --git a/AK/BitStream.h b/AK/BitStream.h index 25dfb265d05..966fd424b49 100644 --- a/AK/BitStream.h +++ b/AK/BitStream.h @@ -34,7 +34,7 @@ public: return m_stream->read_some(bytes); } virtual ErrorOr write_some(ReadonlyBytes bytes) override { return m_stream->write_some(bytes); } - virtual ErrorOr write_entire_buffer(ReadonlyBytes bytes) override { return m_stream->write_entire_buffer(bytes); } + virtual ErrorOr write_until_depleted(ReadonlyBytes bytes) override { return m_stream->write_until_depleted(bytes); } virtual bool is_eof() const override { return m_stream->is_eof() && !m_current_byte.has_value(); } virtual bool is_open() const override { return m_stream->is_open(); } virtual void close() override @@ -141,7 +141,7 @@ public: return m_stream->read_some(bytes); } virtual ErrorOr write_some(ReadonlyBytes bytes) override { return m_stream->write_some(bytes); } - virtual ErrorOr write_entire_buffer(ReadonlyBytes bytes) override { return m_stream->write_entire_buffer(bytes); } + virtual ErrorOr write_until_depleted(ReadonlyBytes bytes) override { return m_stream->write_until_depleted(bytes); } virtual bool is_eof() const override { return m_stream->is_eof() && !m_current_byte.has_value(); } virtual bool is_open() const override { return m_stream->is_open(); } virtual void close() override diff --git a/AK/MemoryStream.cpp b/AK/MemoryStream.cpp index e1131b3cd8f..825998f56ec 100644 --- a/AK/MemoryStream.cpp +++ b/AK/MemoryStream.cpp @@ -89,7 +89,7 @@ ErrorOr FixedMemoryStream::write_some(ReadonlyBytes bytes) return nwritten; } -ErrorOr FixedMemoryStream::write_entire_buffer(ReadonlyBytes bytes) +ErrorOr FixedMemoryStream::write_until_depleted(ReadonlyBytes bytes) { if (remaining() < bytes.size()) return Error::from_string_view_or_print_error_and_return_errno("Write of entire buffer ends past the memory area"sv, EINVAL); diff --git a/AK/MemoryStream.h b/AK/MemoryStream.h index c1fe27a27c4..6ebb3d2e0b1 100644 --- a/AK/MemoryStream.h +++ b/AK/MemoryStream.h @@ -28,7 +28,7 @@ public: virtual ErrorOr seek(i64 offset, SeekMode seek_mode = SeekMode::SetPosition) override; virtual ErrorOr write_some(ReadonlyBytes bytes) override; - virtual ErrorOr write_entire_buffer(ReadonlyBytes bytes) override; + virtual ErrorOr write_until_depleted(ReadonlyBytes bytes) override; Bytes bytes(); ReadonlyBytes bytes() const; diff --git a/AK/Stream.cpp b/AK/Stream.cpp index bf627c3762e..76217ea5fb5 100644 --- a/AK/Stream.cpp +++ b/AK/Stream.cpp @@ -78,7 +78,7 @@ ErrorOr Stream::discard(size_t discarded_bytes) return {}; } -ErrorOr Stream::write_entire_buffer(ReadonlyBytes buffer) +ErrorOr Stream::write_until_depleted(ReadonlyBytes buffer) { size_t nwritten = 0; while (nwritten < buffer.size()) { diff --git a/AK/Stream.h b/AK/Stream.h index 53fd681dab8..559ce311949 100644 --- a/AK/Stream.h +++ b/AK/Stream.h @@ -44,7 +44,7 @@ public: virtual ErrorOr write_some(ReadonlyBytes) = 0; /// Same as write, but does not return until either the entire buffer /// contents are written or an error occurs. - virtual ErrorOr write_entire_buffer(ReadonlyBytes); + virtual ErrorOr write_until_depleted(ReadonlyBytes); template requires(requires(Stream& stream) { { T::read_from_stream(stream) } -> SameAs>; }) @@ -73,7 +73,7 @@ public: requires(Traits::is_trivially_serializable()) ErrorOr write_value(T const& value) { - return write_entire_buffer({ &value, sizeof(value) }); + return write_until_depleted({ &value, sizeof(value) }); } /// Returns whether the stream has reached the end of file. For sockets, diff --git a/Kernel/FileSystem/Ext2FS/Inode.cpp b/Kernel/FileSystem/Ext2FS/Inode.cpp index 3a4b20a80fa..3698cc64679 100644 --- a/Kernel/FileSystem/Ext2FS/Inode.cpp +++ b/Kernel/FileSystem/Ext2FS/Inode.cpp @@ -796,7 +796,7 @@ ErrorOr Ext2FSInode::write_directory(Vector& entries MUST(stream.write_value(entry.record_length)); MUST(stream.write_value(entry.name->length())); MUST(stream.write_value(entry.file_type)); - MUST(stream.write_entire_buffer(entry.name->bytes())); + MUST(stream.write_until_depleted(entry.name->bytes())); int padding = entry.record_length - entry.name->length() - 8; for (int j = 0; j < padding; ++j) MUST(stream.write_value(0)); diff --git a/Kernel/FileSystem/OpenFileDescription.cpp b/Kernel/FileSystem/OpenFileDescription.cpp index 4fe414ec7f3..c4828c8f5d9 100644 --- a/Kernel/FileSystem/OpenFileDescription.cpp +++ b/Kernel/FileSystem/OpenFileDescription.cpp @@ -249,7 +249,7 @@ ErrorOr OpenFileDescription::get_dir_entries(UserOrKernelBuffer& output_ MUST(stream.write_value(entry.inode.index().value())); MUST(stream.write_value(m_inode->fs().internal_file_type_to_directory_entry_type(entry))); MUST(stream.write_value(entry.name.length())); - MUST(stream.write_entire_buffer(entry.name.bytes())); + MUST(stream.write_until_depleted(entry.name.bytes())); return {}; }); diff --git a/Tests/AK/TestMemoryStream.cpp b/Tests/AK/TestMemoryStream.cpp index cbe2cfea2e0..fe93a036cd7 100644 --- a/Tests/AK/TestMemoryStream.cpp +++ b/Tests/AK/TestMemoryStream.cpp @@ -29,7 +29,7 @@ TEST_CASE(allocating_memory_stream_empty) TEST_CASE(allocating_memory_stream_offset_of) { AllocatingMemoryStream stream; - MUST(stream.write_entire_buffer("Well Hello Friends! :^)"sv.bytes())); + MUST(stream.write_until_depleted("Well Hello Friends! :^)"sv.bytes())); { auto offset = MUST(stream.offset_of(" "sv.bytes())); @@ -79,12 +79,12 @@ TEST_CASE(allocating_memory_stream_offset_of_oob) // First, fill exactly one chunk. for (size_t i = 0; i < 256; ++i) - MUST(stream.write_entire_buffer("AAAAAAAAAAAAAAAA"sv.bytes())); + MUST(stream.write_until_depleted("AAAAAAAAAAAAAAAA"sv.bytes())); // Then discard it all. MUST(stream.discard(4096)); // Now we can write into this chunk again, knowing that it's initialized to all 'A's. - MUST(stream.write_entire_buffer("Well Hello Friends! :^)"sv.bytes())); + MUST(stream.write_until_depleted("Well Hello Friends! :^)"sv.bytes())); { auto offset = MUST(stream.offset_of("A"sv.bytes())); diff --git a/Tests/LibCore/TestLibCoreStream.cpp b/Tests/LibCore/TestLibCoreStream.cpp index cc835b2a500..23003a1a115 100644 --- a/Tests/LibCore/TestLibCoreStream.cpp +++ b/Tests/LibCore/TestLibCoreStream.cpp @@ -221,7 +221,7 @@ TEST_CASE(tcp_socket_write) auto server_socket = maybe_server_socket.release_value(); EXPECT(!server_socket->set_blocking(true).is_error()); - EXPECT(!client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); + EXPECT(!client_socket->write_until_depleted({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); client_socket->close(); auto maybe_receive_buffer = ByteBuffer::create_uninitialized(64); @@ -285,7 +285,7 @@ TEST_CASE(udp_socket_read_write) auto client_socket = maybe_client_socket.release_value(); EXPECT(client_socket->is_open()); - EXPECT(!client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); + EXPECT(!client_socket->write_until_depleted({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); // FIXME: UDPServer::receive sadly doesn't give us a way to block on it, // currently. @@ -405,7 +405,7 @@ TEST_CASE(local_socket_write) EXPECT(!maybe_client_socket.is_error()); auto client_socket = maybe_client_socket.release_value(); - EXPECT(!client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); + EXPECT(!client_socket->write_until_depleted({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); client_socket->close(); return 0; diff --git a/Tests/LibGL/TestRender.cpp b/Tests/LibGL/TestRender.cpp index c5a54326fc0..35f38e8a210 100644 --- a/Tests/LibGL/TestRender.cpp +++ b/Tests/LibGL/TestRender.cpp @@ -37,7 +37,7 @@ static void expect_bitmap_equals_reference(Gfx::Bitmap const& bitmap, StringView auto target_path = LexicalPath("/home/anon").append(reference_filename); auto qoi_buffer = MUST(Gfx::QOIWriter::encode(bitmap)); auto qoi_output_stream = MUST(Core::File::open(target_path.string(), Core::File::OpenMode::Write)); - MUST(qoi_output_stream->write_entire_buffer(qoi_buffer)); + MUST(qoi_output_stream->write_until_depleted(qoi_buffer)); } auto reference_image_path = DeprecatedString::formatted(REFERENCE_IMAGE_DIR "/{}", reference_filename); diff --git a/Tests/LibJS/test-test262.cpp b/Tests/LibJS/test-test262.cpp index 086ca1b34e7..a1ec4dce441 100644 --- a/Tests/LibJS/test-test262.cpp +++ b/Tests/LibJS/test-test262.cpp @@ -161,7 +161,7 @@ public: } for (DeprecatedString const& line : lines) { - if (m_output->write_entire_buffer(DeprecatedString::formatted("{}\n", line).bytes()).is_error()) + if (m_output->write_until_depleted(DeprecatedString::formatted("{}\n", line).bytes()).is_error()) break; } @@ -427,7 +427,7 @@ void write_per_file(HashMap const& result_map, Vectorwrite_entire_buffer(complete_results.to_deprecated_string().bytes()).is_error()) + if (file->write_until_depleted(complete_results.to_deprecated_string().bytes()).is_error()) warnln("Failed to write per-file"); file->close(); } diff --git a/Tests/LibTLS/TestTLSHandshake.cpp b/Tests/LibTLS/TestTLSHandshake.cpp index 13712a0e8a7..60c5f4e0159 100644 --- a/Tests/LibTLS/TestTLSHandshake.cpp +++ b/Tests/LibTLS/TestTLSHandshake.cpp @@ -96,17 +96,17 @@ TEST_CASE(test_TLS_hello_handshake) loop.quit(0); }; - if (tls->write_entire_buffer("GET / HTTP/1.1\r\nHost: "_b).is_error()) { + if (tls->write_until_depleted("GET / HTTP/1.1\r\nHost: "_b).is_error()) { FAIL("write(0) failed"); return; } auto the_server = DEFAULT_SERVER; - if (tls->write_entire_buffer(the_server.bytes()).is_error()) { + if (tls->write_until_depleted(the_server.bytes()).is_error()) { FAIL("write(1) failed"); return; } - if (tls->write_entire_buffer("\r\nConnection : close\r\n\r\n"_b).is_error()) { + if (tls->write_until_depleted("\r\nConnection : close\r\n\r\n"_b).is_error()) { FAIL("write(2) failed"); return; } diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 81b3ca6569c..77a4a692f09 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -177,7 +177,7 @@ ErrorOr Image::export_bmp_to_file(NonnullOwnPtr stream, bool prese auto bitmap = TRY(compose_bitmap(bitmap_format)); auto encoded_data = TRY(Gfx::BMPWriter::encode(*bitmap)); - TRY(stream->write_entire_buffer(encoded_data)); + TRY(stream->write_until_depleted(encoded_data)); return {}; } @@ -187,7 +187,7 @@ ErrorOr Image::export_png_to_file(NonnullOwnPtr stream, bool prese auto bitmap = TRY(compose_bitmap(bitmap_format)); auto encoded_data = TRY(Gfx::PNGWriter::encode(*bitmap)); - TRY(stream->write_entire_buffer(encoded_data)); + TRY(stream->write_until_depleted(encoded_data)); return {}; } @@ -196,7 +196,7 @@ ErrorOr Image::export_qoi_to_file(NonnullOwnPtr stream) const auto bitmap = TRY(compose_bitmap(Gfx::BitmapFormat::BGRA8888)); auto encoded_data = TRY(Gfx::QOIWriter::encode(bitmap)); - TRY(stream->write_entire_buffer(encoded_data)); + TRY(stream->write_until_depleted(encoded_data)); return {}; } diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 6fb70d6d003..74056c11042 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -793,7 +793,7 @@ ErrorOr ImageEditor::save_project_to_file(NonnullOwnPtr file) TRY(json_guides.finish()); TRY(json.finish()); - TRY(file->write_entire_buffer(builder.string_view().bytes())); + TRY(file->write_until_depleted(builder.string_view().bytes())); return {}; } diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp index 7b53dde7ebb..ab27c92ce93 100644 --- a/Userland/Applications/PixelPaint/PaletteWidget.cpp +++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp @@ -248,8 +248,8 @@ ErrorOr> PaletteWidget::load_palette_path(DeprecatedString const& ErrorOr PaletteWidget::save_palette_file(Vector palette, NonnullOwnPtr file) { for (auto& color : palette) { - TRY(file->write_entire_buffer(color.to_deprecated_string_without_alpha().bytes())); - TRY(file->write_entire_buffer({ "\n", 1 })); + TRY(file->write_until_depleted(color.to_deprecated_string_without_alpha().bytes())); + TRY(file->write_until_depleted({ "\n", 1 })); } return {}; } diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp index 708126ed073..ed59cea6b22 100644 --- a/Userland/Applications/Spreadsheet/ExportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp @@ -205,7 +205,7 @@ ErrorOr ExportDialog::make_and_run_for(StringView mime, Core::File& file, array.append(sheet->to_json()); auto file_content = array.to_deprecated_string(); - return file.write_entire_buffer(file_content.bytes()); + return file.write_until_depleted(file_content.bytes()); }; if (mime == "text/csv") { diff --git a/Userland/Applications/Spreadsheet/Writers/XSV.h b/Userland/Applications/Spreadsheet/Writers/XSV.h index f7272032c97..2ea61a0e207 100644 --- a/Userland/Applications/Spreadsheet/Writers/XSV.h +++ b/Userland/Applications/Spreadsheet/Writers/XSV.h @@ -48,7 +48,7 @@ public: auto with_headers = has_flag(writer.m_behaviors, WriterBehavior::WriteHeaders); if (with_headers) { TRY(writer.write_row(writer.m_names)); - TRY(writer.m_output.write_entire_buffer({ "\n", 1 })); + TRY(writer.m_output.write_until_depleted({ "\n", 1 })); } for (auto&& row : writer.m_data) { @@ -58,7 +58,7 @@ public: } TRY(writer.write_row(row)); - TRY(writer.m_output.write_entire_buffer({ "\n", 1 })); + TRY(writer.m_output.write_until_depleted({ "\n", 1 })); } return {}; } @@ -72,7 +72,7 @@ public: auto with_headers = has_flag(writer.m_behaviors, WriterBehavior::WriteHeaders); if (with_headers) { TRY(writer.write_row(writer.m_names)); - TRY(writer.m_output.write_entire_buffer({ "\n", 1 })); + TRY(writer.m_output.write_until_depleted({ "\n", 1 })); ++lines_written; } @@ -83,7 +83,7 @@ public: } TRY(writer.write_row(row)); - TRY(writer.m_output.write_entire_buffer({ "\n", 1 })); + TRY(writer.m_output.write_until_depleted({ "\n", 1 })); ++lines_written; if (lines_written >= max_preview_lines) @@ -110,7 +110,7 @@ private: bool first = true; for (auto&& entry : row) { if (!first) { - TRY(m_output.write_entire_buffer(m_traits.separator.bytes())); + TRY(m_output.write_until_depleted(m_traits.separator.bytes())); } first = false; TRY(write_entry(entry)); @@ -136,33 +136,33 @@ private: if (safe_to_write_normally) { if (!string.is_empty()) - TRY(m_output.write_entire_buffer(string.bytes())); + TRY(m_output.write_until_depleted(string.bytes())); return {}; } - TRY(m_output.write_entire_buffer(m_traits.quote.bytes())); + TRY(m_output.write_until_depleted(m_traits.quote.bytes())); GenericLexer lexer(string); while (!lexer.is_eof()) { if (lexer.consume_specific(m_traits.quote)) { switch (m_traits.quote_escape) { case WriterTraits::Repeat: - TRY(m_output.write_entire_buffer(m_traits.quote.bytes())); - TRY(m_output.write_entire_buffer(m_traits.quote.bytes())); + TRY(m_output.write_until_depleted(m_traits.quote.bytes())); + TRY(m_output.write_until_depleted(m_traits.quote.bytes())); break; case WriterTraits::Backslash: - TRY(m_output.write_entire_buffer({ "\\", 1 })); - TRY(m_output.write_entire_buffer(m_traits.quote.bytes())); + TRY(m_output.write_until_depleted({ "\\", 1 })); + TRY(m_output.write_until_depleted(m_traits.quote.bytes())); break; } continue; } auto ch = lexer.consume(); - TRY(m_output.write_entire_buffer({ &ch, 1 })); + TRY(m_output.write_until_depleted({ &ch, 1 })); } - TRY(m_output.write_entire_buffer(m_traits.quote.bytes())); + TRY(m_output.write_until_depleted(m_traits.quote.bytes())); return {}; } diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 4e7bf9ca81a..ce5abf38842 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -1807,7 +1807,7 @@ ErrorOr> HackStudioWidget::create_open_project_config return maybe_error.release_error(); auto file = TRY(Core::File::open(absolute_config_file_path, Core::File::OpenMode::Write)); - TRY(file->write_entire_buffer( + TRY(file->write_until_depleted( "{\n" " \"build_command\": \"your build command here\",\n" " \"run_command\": \"your run command here\"\n" diff --git a/Userland/DevTools/HackStudio/ProjectBuilder.cpp b/Userland/DevTools/HackStudio/ProjectBuilder.cpp index 5ec9544cc3f..b18ee7a99e9 100644 --- a/Userland/DevTools/HackStudio/ProjectBuilder.cpp +++ b/Userland/DevTools/HackStudio/ProjectBuilder.cpp @@ -135,7 +135,7 @@ ErrorOr ProjectBuilder::initialize_build_directory() MUST(Core::DeprecatedFile::remove(cmake_file_path, Core::DeprecatedFile::RecursionMode::Disallowed)); auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Write)); - TRY(cmake_file->write_entire_buffer(generate_cmake_file_content().bytes())); + TRY(cmake_file->write_until_depleted(generate_cmake_file_content().bytes())); TRY(m_terminal->run_command(DeprecatedString::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}" " -DENABLE_UNICODE_DATABASE_DOWNLOAD=OFF", diff --git a/Userland/DevTools/SQLStudio/ScriptEditor.cpp b/Userland/DevTools/SQLStudio/ScriptEditor.cpp index 331ff35a59b..2cf378e0201 100644 --- a/Userland/DevTools/SQLStudio/ScriptEditor.cpp +++ b/Userland/DevTools/SQLStudio/ScriptEditor.cpp @@ -42,7 +42,7 @@ static ErrorOr save_text_to_file(StringView filename, DeprecatedString tex auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write)); if (!text.is_empty()) - TRY(file->write_entire_buffer(text.bytes())); + TRY(file->write_until_depleted(text.bytes())); return {}; } diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index 93e0c41a1f4..a0207c4acfd 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -509,7 +509,7 @@ void Emulator::emit_profile_sample(Stream& output) builder.appendff(R"~(, {{"type": "sample", "pid": {}, "tid": {}, "timestamp": {}, "lost_samples": 0, "stack": [)~", getpid(), gettid(), tv.tv_sec * 1000 + tv.tv_usec / 1000); builder.join(',', raw_backtrace()); builder.append("]}\n"sv); - output.write_entire_buffer(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors(); + output.write_until_depleted(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors(); } void Emulator::emit_profile_event(Stream& output, StringView event_name, DeprecatedString const& contents) @@ -519,7 +519,7 @@ void Emulator::emit_profile_event(Stream& output, StringView event_name, Depreca gettimeofday(&tv, nullptr); builder.appendff(R"~(, {{"type": "{}", "pid": {}, "tid": {}, "timestamp": {}, "lost_samples": 0, "stack": [], {}}})~", event_name, getpid(), gettid(), tv.tv_sec * 1000 + tv.tv_usec / 1000, contents); builder.append('\n'); - output.write_entire_buffer(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors(); + output.write_until_depleted(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors(); } DeprecatedString Emulator::create_instruction_line(FlatPtr address, X86::Instruction const& insn) diff --git a/Userland/DevTools/UserspaceEmulator/main.cpp b/Userland/DevTools/UserspaceEmulator/main.cpp index 83498e66e90..18796d1333b 100644 --- a/Userland/DevTools/UserspaceEmulator/main.cpp +++ b/Userland/DevTools/UserspaceEmulator/main.cpp @@ -70,10 +70,10 @@ int main(int argc, char** argv, char** env) profile_strings = make>>(); profile_string_id_map = make>(); - profile_stream->write_entire_buffer(R"({"events":[)"sv.bytes()).release_value_but_fixme_should_propagate_errors(); + profile_stream->write_until_depleted(R"({"events":[)"sv.bytes()).release_value_but_fixme_should_propagate_errors(); timeval tv {}; gettimeofday(&tv, nullptr); - profile_stream->write_entire_buffer( + profile_stream->write_until_depleted( DeprecatedString::formatted( R"~({{"type": "process_create", "parent_pid": 1, "executable": "{}", "pid": {}, "tid": {}, "timestamp": {}, "lost_samples": 0, "stack": []}})~", executable_path, getpid(), gettid(), tv.tv_sec * 1000 + tv.tv_usec / 1000) @@ -109,13 +109,13 @@ int main(int argc, char** argv, char** env) int rc = emulator.exec(); if (dump_profile) { - emulator.profile_stream().write_entire_buffer("], \"strings\": ["sv.bytes()).release_value_but_fixme_should_propagate_errors(); + emulator.profile_stream().write_until_depleted("], \"strings\": ["sv.bytes()).release_value_but_fixme_should_propagate_errors(); if (emulator.profiler_strings().size()) { for (size_t i = 0; i < emulator.profiler_strings().size() - 1; ++i) - emulator.profile_stream().write_entire_buffer(DeprecatedString::formatted("\"{}\", ", emulator.profiler_strings().at(i)).bytes()).release_value_but_fixme_should_propagate_errors(); - emulator.profile_stream().write_entire_buffer(DeprecatedString::formatted("\"{}\"", emulator.profiler_strings().last()).bytes()).release_value_but_fixme_should_propagate_errors(); + emulator.profile_stream().write_until_depleted(DeprecatedString::formatted("\"{}\", ", emulator.profiler_strings().at(i)).bytes()).release_value_but_fixme_should_propagate_errors(); + emulator.profile_stream().write_until_depleted(DeprecatedString::formatted("\"{}\"", emulator.profiler_strings().last()).bytes()).release_value_but_fixme_should_propagate_errors(); } - emulator.profile_stream().write_entire_buffer("]}"sv.bytes()).release_value_but_fixme_should_propagate_errors(); + emulator.profile_stream().write_until_depleted("]}"sv.bytes()).release_value_but_fixme_should_propagate_errors(); } return rc; } diff --git a/Userland/Libraries/LibArchive/TarStream.cpp b/Userland/Libraries/LibArchive/TarStream.cpp index 1515185f2f9..f876dd1cab4 100644 --- a/Userland/Libraries/LibArchive/TarStream.cpp +++ b/Userland/Libraries/LibArchive/TarStream.cpp @@ -154,9 +154,9 @@ ErrorOr TarOutputStream::add_directory(StringView path, mode_t mode) header.set_magic(gnu_magic); header.set_version(gnu_version); TRY(header.calculate_checksum()); - TRY(m_stream->write_entire_buffer(Bytes { &header, sizeof(header) })); + TRY(m_stream->write_until_depleted(Bytes { &header, sizeof(header) })); u8 padding[block_size] = { 0 }; - TRY(m_stream->write_entire_buffer(Bytes { &padding, block_size - sizeof(header) })); + TRY(m_stream->write_until_depleted(Bytes { &padding, block_size - sizeof(header) })); return {}; } @@ -171,14 +171,14 @@ ErrorOr TarOutputStream::add_file(StringView path, mode_t mode, ReadonlyBy header.set_magic(gnu_magic); header.set_version(gnu_version); TRY(header.calculate_checksum()); - TRY(m_stream->write_entire_buffer(ReadonlyBytes { &header, sizeof(header) })); + TRY(m_stream->write_until_depleted(ReadonlyBytes { &header, sizeof(header) })); constexpr Array padding { 0 }; - TRY(m_stream->write_entire_buffer(ReadonlyBytes { &padding, block_size - sizeof(header) })); + TRY(m_stream->write_until_depleted(ReadonlyBytes { &padding, block_size - sizeof(header) })); size_t n_written = 0; while (n_written < bytes.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) })); + TRY(m_stream->write_until_depleted(ReadonlyBytes { &padding, block_size - (n_written % block_size) })); return {}; } @@ -194,9 +194,9 @@ ErrorOr TarOutputStream::add_link(StringView path, mode_t mode, StringView header.set_version(gnu_version); header.set_link_name(link_name); TRY(header.calculate_checksum()); - TRY(m_stream->write_entire_buffer(Bytes { &header, sizeof(header) })); + TRY(m_stream->write_until_depleted(Bytes { &header, sizeof(header) })); u8 padding[block_size] = { 0 }; - TRY(m_stream->write_entire_buffer(Bytes { &padding, block_size - sizeof(header) })); + TRY(m_stream->write_until_depleted(Bytes { &padding, block_size - sizeof(header) })); return {}; } @@ -205,8 +205,8 @@ ErrorOr TarOutputStream::finish() VERIFY(!m_finished); constexpr Array padding { 0 }; // 2 empty records that are used to signify the end of the archive. - TRY(m_stream->write_entire_buffer(ReadonlyBytes { &padding, block_size })); - TRY(m_stream->write_entire_buffer(ReadonlyBytes { &padding, block_size })); + TRY(m_stream->write_until_depleted(ReadonlyBytes { &padding, block_size })); + TRY(m_stream->write_until_depleted(ReadonlyBytes { &padding, block_size })); m_finished = true; return {}; } diff --git a/Userland/Libraries/LibArchive/Zip.h b/Userland/Libraries/LibArchive/Zip.h index e7f1ccbf596..453464d1dc7 100644 --- a/Userland/Libraries/LibArchive/Zip.h +++ b/Userland/Libraries/LibArchive/Zip.h @@ -60,10 +60,10 @@ struct [[gnu::packed]] EndOfCentralDirectory { ErrorOr write(Stream& stream) const { auto write_value = [&stream](auto value) { - return stream.write_entire_buffer({ &value, sizeof(value) }); + return stream.write_until_depleted({ &value, sizeof(value) }); }; - TRY(stream.write_entire_buffer(signature)); + TRY(stream.write_until_depleted(signature)); TRY(write_value(disk_number)); TRY(write_value(central_directory_start_disk)); TRY(write_value(disk_records_count)); @@ -72,7 +72,7 @@ struct [[gnu::packed]] EndOfCentralDirectory { TRY(write_value(central_directory_offset)); TRY(write_value(comment_length)); if (comment_length > 0) - TRY(stream.write_entire_buffer({ comment, comment_length })); + TRY(stream.write_until_depleted({ comment, comment_length })); return {}; } }; @@ -146,10 +146,10 @@ struct [[gnu::packed]] CentralDirectoryRecord { ErrorOr write(Stream& stream) const { auto write_value = [&stream](auto value) { - return stream.write_entire_buffer({ &value, sizeof(value) }); + return stream.write_until_depleted({ &value, sizeof(value) }); }; - TRY(stream.write_entire_buffer(signature)); + TRY(stream.write_until_depleted(signature)); TRY(write_value(made_by_version)); TRY(write_value(minimum_version)); TRY(write_value(general_purpose_flags.flags)); @@ -167,11 +167,11 @@ struct [[gnu::packed]] CentralDirectoryRecord { TRY(write_value(external_attributes)); TRY(write_value(local_file_header_offset)); if (name_length > 0) - TRY(stream.write_entire_buffer({ name, name_length })); + TRY(stream.write_until_depleted({ name, name_length })); if (extra_data_length > 0) - TRY(stream.write_entire_buffer({ extra_data, extra_data_length })); + TRY(stream.write_until_depleted({ extra_data, extra_data_length })); if (comment_length > 0) - TRY(stream.write_entire_buffer({ comment, comment_length })); + TRY(stream.write_until_depleted({ comment, comment_length })); return {}; } @@ -215,10 +215,10 @@ struct [[gnu::packed]] LocalFileHeader { ErrorOr write(Stream& stream) const { auto write_value = [&stream](auto value) { - return stream.write_entire_buffer({ &value, sizeof(value) }); + return stream.write_until_depleted({ &value, sizeof(value) }); }; - TRY(stream.write_entire_buffer(signature)); + TRY(stream.write_until_depleted(signature)); TRY(write_value(minimum_version)); TRY(write_value(general_purpose_flags.flags)); TRY(write_value(compression_method)); @@ -230,11 +230,11 @@ struct [[gnu::packed]] LocalFileHeader { TRY(write_value(name_length)); TRY(write_value(extra_data_length)); if (name_length > 0) - TRY(stream.write_entire_buffer({ name, name_length })); + TRY(stream.write_until_depleted({ name, name_length })); if (extra_data_length > 0) - TRY(stream.write_entire_buffer({ extra_data, extra_data_length })); + TRY(stream.write_until_depleted({ extra_data, extra_data_length })); if (compressed_size > 0) - TRY(stream.write_entire_buffer({ compressed_data, compressed_size })); + TRY(stream.write_until_depleted({ compressed_data, compressed_size })); return {}; } }; diff --git a/Userland/Libraries/LibCompress/Deflate.cpp b/Userland/Libraries/LibCompress/Deflate.cpp index 66fc163a6c8..e7a84943056 100644 --- a/Userland/Libraries/LibCompress/Deflate.cpp +++ b/Userland/Libraries/LibCompress/Deflate.cpp @@ -325,7 +325,7 @@ ErrorOr DeflateDecompressor::decompress_all(ReadonlyBytes bytes) auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); while (!deflate_stream->is_eof()) { auto const slice = TRY(deflate_stream->read_some(buffer)); - TRY(output_stream.write_entire_buffer(slice)); + TRY(output_stream.write_until_depleted(slice)); } auto output_buffer = TRY(ByteBuffer::create_uninitialized(output_stream.used_buffer_size())); @@ -929,10 +929,10 @@ ErrorOr DeflateCompressor::flush() TRY(m_output_stream->write_bits(0b00u, 2)); // no compression TRY(m_output_stream->align_to_byte_boundary()); LittleEndian len = m_pending_block_size; - TRY(m_output_stream->write_entire_buffer(len.bytes())); + TRY(m_output_stream->write_until_depleted(len.bytes())); LittleEndian nlen = ~m_pending_block_size; - TRY(m_output_stream->write_entire_buffer(nlen.bytes())); - TRY(m_output_stream->write_entire_buffer(pending_block().slice(0, m_pending_block_size))); + TRY(m_output_stream->write_until_depleted(nlen.bytes())); + TRY(m_output_stream->write_until_depleted(pending_block().slice(0, m_pending_block_size))); return {}; }; @@ -1023,7 +1023,7 @@ ErrorOr DeflateCompressor::compress_all(ReadonlyBytes bytes, Compres auto output_stream = TRY(try_make()); auto deflate_stream = TRY(DeflateCompressor::construct(MaybeOwned(*output_stream), compression_level)); - TRY(deflate_stream->write_entire_buffer(bytes)); + TRY(deflate_stream->write_until_depleted(bytes)); TRY(deflate_stream->final_flush()); auto buffer = TRY(ByteBuffer::create_uninitialized(output_stream->used_buffer_size())); diff --git a/Userland/Libraries/LibCompress/Gzip.cpp b/Userland/Libraries/LibCompress/Gzip.cpp index b7b2c128603..c5abab5657f 100644 --- a/Userland/Libraries/LibCompress/Gzip.cpp +++ b/Userland/Libraries/LibCompress/Gzip.cpp @@ -175,7 +175,7 @@ ErrorOr GzipDecompressor::decompress_all(ReadonlyBytes bytes) auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); while (!gzip_stream->is_eof()) { auto const data = TRY(gzip_stream->read_some(buffer)); - TRY(output_stream.write_entire_buffer(data)); + TRY(output_stream.write_until_depleted(data)); } auto output_buffer = TRY(ByteBuffer::create_uninitialized(output_stream.used_buffer_size())); @@ -210,16 +210,16 @@ ErrorOr GzipCompressor::write_some(ReadonlyBytes bytes) header.modification_time = 0; header.extra_flags = 3; // DEFLATE sets 2 for maximum compression and 4 for minimum compression header.operating_system = 3; // unix - TRY(m_output_stream->write_entire_buffer({ &header, sizeof(header) })); + TRY(m_output_stream->write_until_depleted({ &header, sizeof(header) })); auto compressed_stream = TRY(DeflateCompressor::construct(MaybeOwned(*m_output_stream))); - TRY(compressed_stream->write_entire_buffer(bytes)); + TRY(compressed_stream->write_until_depleted(bytes)); TRY(compressed_stream->final_flush()); Crypto::Checksum::CRC32 crc32; crc32.update(bytes); LittleEndian digest = crc32.digest(); LittleEndian size = bytes.size(); - TRY(m_output_stream->write_entire_buffer(digest.bytes())); - TRY(m_output_stream->write_entire_buffer(size.bytes())); + TRY(m_output_stream->write_until_depleted(digest.bytes())); + TRY(m_output_stream->write_until_depleted(size.bytes())); return bytes.size(); } @@ -242,7 +242,7 @@ ErrorOr GzipCompressor::compress_all(ReadonlyBytes bytes) auto output_stream = TRY(try_make()); GzipCompressor gzip_stream { MaybeOwned(*output_stream) }; - TRY(gzip_stream.write_entire_buffer(bytes)); + TRY(gzip_stream.write_until_depleted(bytes)); auto buffer = TRY(ByteBuffer::create_uninitialized(output_stream->used_buffer_size())); TRY(output_stream->read_until_filled(buffer.bytes())); diff --git a/Userland/Libraries/LibCompress/Zlib.cpp b/Userland/Libraries/LibCompress/Zlib.cpp index 3b3f4af2191..ccf30ec89a2 100644 --- a/Userland/Libraries/LibCompress/Zlib.cpp +++ b/Userland/Libraries/LibCompress/Zlib.cpp @@ -168,7 +168,7 @@ ErrorOr ZlibCompressor::compress_all(ReadonlyBytes bytes, ZlibCompre auto output_stream = TRY(try_make()); auto zlib_stream = TRY(ZlibCompressor::construct(MaybeOwned(*output_stream), compression_level)); - TRY(zlib_stream->write_entire_buffer(bytes)); + TRY(zlib_stream->write_until_depleted(bytes)); TRY(zlib_stream->finish()); diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.cpp b/Userland/Libraries/LibCrypto/ASN1/DER.cpp index e5c069c9173..c68d3b524f3 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.cpp +++ b/Userland/Libraries/LibCrypto/ASN1/DER.cpp @@ -238,7 +238,7 @@ ErrorOr pretty_print(Decoder& decoder, Stream& stream, int indent) TRY(decoder.enter()); builder.append('\n'); - TRY(stream.write_entire_buffer(builder.string_view().bytes())); + TRY(stream.write_until_depleted(builder.string_view().bytes())); TRY(pretty_print(decoder, stream, indent + 2)); @@ -314,7 +314,7 @@ ErrorOr pretty_print(Decoder& decoder, Stream& stream, int indent) } builder.append('\n'); - TRY(stream.write_entire_buffer(builder.string_view().bytes())); + TRY(stream.write_until_depleted(builder.string_view().bytes())); } return {}; diff --git a/Userland/Libraries/LibDNS/Name.cpp b/Userland/Libraries/LibDNS/Name.cpp index b6582b97174..42262025311 100644 --- a/Userland/Libraries/LibDNS/Name.cpp +++ b/Userland/Libraries/LibDNS/Name.cpp @@ -81,7 +81,7 @@ ErrorOr Name::write_to_stream(Stream& stream) const auto parts = as_string().split_view('.'); for (auto& part : parts) { TRY(stream.write_value(part.length())); - TRY(stream.write_entire_buffer(part.bytes())); + TRY(stream.write_until_depleted(part.bytes())); } TRY(stream.write_value('\0')); return {}; diff --git a/Userland/Libraries/LibDNS/Packet.cpp b/Userland/Libraries/LibDNS/Packet.cpp index b0d323f43e6..6b75b5e9731 100644 --- a/Userland/Libraries/LibDNS/Packet.cpp +++ b/Userland/Libraries/LibDNS/Packet.cpp @@ -67,7 +67,7 @@ ErrorOr Packet::to_byte_buffer() const TRY(stream.write_value(name)); } else { TRY(stream.write_value(htons(answer.record_data().length()))); - TRY(stream.write_entire_buffer(answer.record_data().bytes())); + TRY(stream.write_until_depleted(answer.record_data().bytes())); } } diff --git a/Userland/Libraries/LibGemini/Job.cpp b/Userland/Libraries/LibGemini/Job.cpp index 9cfb6483f08..6e8f9b013f6 100644 --- a/Userland/Libraries/LibGemini/Job.cpp +++ b/Userland/Libraries/LibGemini/Job.cpp @@ -76,7 +76,7 @@ bool Job::can_read() const bool Job::write(ReadonlyBytes bytes) { - return !m_socket->write_entire_buffer(bytes).is_error(); + return !m_socket->write_until_depleted(bytes).is_error(); } void Job::flush_received_buffers() diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index d1422db02d5..8f5c4c7c95c 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -267,7 +267,7 @@ ErrorOr Bitmap::serialize_to_byte_buffer() const } auto size = size_in_bytes(); - TRY(stream.write_entire_buffer({ scanline(0), size })); + TRY(stream.write_until_depleted({ scanline(0), size })); VERIFY(TRY(stream.tell()) == TRY(stream.size())); diff --git a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp index 4a66a08c523..074d78e720c 100644 --- a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp @@ -259,10 +259,10 @@ ErrorOr BitmapFont::write_to_file(DeprecatedString const& path) auto stream = TRY(Core::File::open(path, Core::File::OpenMode::Write)); size_t bytes_per_glyph = sizeof(u32) * m_glyph_height; - TRY(stream->write_entire_buffer({ &header, sizeof(header) })); - TRY(stream->write_entire_buffer({ m_range_mask, m_range_mask_size })); - TRY(stream->write_entire_buffer({ m_rows, m_glyph_count * bytes_per_glyph })); - TRY(stream->write_entire_buffer({ m_glyph_widths, m_glyph_count })); + TRY(stream->write_until_depleted({ &header, sizeof(header) })); + TRY(stream->write_until_depleted({ m_range_mask, m_range_mask_size })); + TRY(stream->write_until_depleted({ m_rows, m_glyph_count * bytes_per_glyph })); + TRY(stream->write_until_depleted({ m_glyph_widths, m_glyph_count })); return {}; } diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp index 1f308b214e2..63d8c4a63c8 100644 --- a/Userland/Libraries/LibHTTP/Job.cpp +++ b/Userland/Libraries/LibHTTP/Job.cpp @@ -202,7 +202,7 @@ void Job::on_socket_connected() dbgln("{}", DeprecatedString::copy(raw_request)); } - bool success = !m_socket->write_entire_buffer(raw_request).is_error(); + bool success = !m_socket->write_until_depleted(raw_request).is_error(); if (!success) deferred_invoke([this] { did_fail(Core::NetworkJob::Error::TransmissionFailed); }); diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index 476ef66706c..6d8f9c4a787 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -606,7 +606,7 @@ ErrorOr Editor::interrupted() TRY(reposition_cursor(*stderr_stream, true)); if (TRY(m_suggestion_display->cleanup())) TRY(reposition_cursor(*stderr_stream, true)); - TRY(stderr_stream->write_entire_buffer("\n"sv.bytes())); + TRY(stderr_stream->write_until_depleted("\n"sv.bytes())); } m_buffer.clear(); m_chars_touched_in_the_middle = buffer().size(); @@ -667,7 +667,7 @@ ErrorOr Editor::really_quit_event_loop() { auto stderr_stream = TRY(Core::File::standard_error()); TRY(reposition_cursor(*stderr_stream, true)); - TRY(stderr_stream->write_entire_buffer("\n"sv.bytes())); + TRY(stderr_stream->write_until_depleted("\n"sv.bytes())); } auto string = line(); m_buffer.clear(); @@ -734,7 +734,7 @@ auto Editor::get_line(DeprecatedString const& prompt) -> Resultwrite_entire_buffer("\n"sv.bytes()).release_value_but_fixme_should_propagate_errors(); + stderr_stream->write_until_depleted("\n"sv.bytes()).release_value_but_fixme_should_propagate_errors(); VT::move_relative(-static_cast(prompt_lines), 0, *stderr_stream).release_value_but_fixme_should_propagate_errors(); } @@ -1375,13 +1375,13 @@ ErrorOr Editor::refresh_display() if (m_origin_row + current_num_lines > m_num_lines) { if (current_num_lines > m_num_lines) { for (size_t i = 0; i < m_num_lines; ++i) - TRY(output_stream.write_entire_buffer("\n"sv.bytes())); + TRY(output_stream.write_until_depleted("\n"sv.bytes())); m_origin_row = 0; } else { auto old_origin_row = m_origin_row; m_origin_row = m_num_lines - current_num_lines + 1; for (size_t i = 0; i < old_origin_row - m_origin_row; ++i) - TRY(output_stream.write_entire_buffer("\n"sv.bytes())); + TRY(output_stream.write_until_depleted("\n"sv.bytes())); } } // Do not call hook on pure cursor movement. @@ -1400,7 +1400,7 @@ ErrorOr Editor::refresh_display() if (!m_refresh_needed && m_cursor == m_buffer.size()) { // Just write the characters out and continue, // no need to refresh the entire line. - TRY(output_stream.write_entire_buffer(m_pending_chars)); + TRY(output_stream.write_until_depleted(m_pending_chars)); m_pending_chars.clear(); m_drawn_cursor = m_cursor; m_drawn_end_of_line_offset = m_buffer.size(); @@ -1481,12 +1481,12 @@ ErrorOr Editor::refresh_display() builder.append(Utf32View { &c, 1 }); if (should_print_masked) - TRY(output_stream.write_entire_buffer("\033[7m"sv.bytes())); + TRY(output_stream.write_until_depleted("\033[7m"sv.bytes())); - TRY(output_stream.write_entire_buffer(builder.string_view().bytes())); + TRY(output_stream.write_until_depleted(builder.string_view().bytes())); if (should_print_masked) - TRY(output_stream.write_entire_buffer("\033[27m"sv.bytes())); + TRY(output_stream.write_until_depleted("\033[27m"sv.bytes())); return {}; }; @@ -1544,7 +1544,7 @@ ErrorOr Editor::refresh_display() } TRY(VT::move_absolute(m_origin_row, m_origin_column, output_stream)); - TRY(output_stream.write_entire_buffer(m_new_prompt.bytes())); + TRY(output_stream.write_until_depleted(m_new_prompt.bytes())); TRY(VT::clear_to_end_of_line(output_stream)); StringBuilder builder; @@ -1606,7 +1606,7 @@ ErrorOr Editor::reposition_cursor(Stream& stream, bool to_end) ErrorOr VT::move_absolute(u32 row, u32 col, Stream& stream) { - return stream.write_entire_buffer(DeprecatedString::formatted("\033[{};{}H", row, col).bytes()); + return stream.write_until_depleted(DeprecatedString::formatted("\033[{};{}H", row, col).bytes()); } ErrorOr VT::move_relative(int row, int col, Stream& stream) @@ -1623,9 +1623,9 @@ ErrorOr VT::move_relative(int row, int col, Stream& stream) col = -col; if (row > 0) - TRY(stream.write_entire_buffer(DeprecatedString::formatted("\033[{}{}", row, x_op).bytes())); + TRY(stream.write_until_depleted(DeprecatedString::formatted("\033[{}{}", row, x_op).bytes())); if (col > 0) - TRY(stream.write_entire_buffer(DeprecatedString::formatted("\033[{}{}", col, y_op).bytes())); + TRY(stream.write_until_depleted(DeprecatedString::formatted("\033[{}{}", col, y_op).bytes())); return {}; } @@ -1764,16 +1764,16 @@ DeprecatedString Style::to_deprecated_string() const ErrorOr VT::apply_style(Style const& style, Stream& stream, bool is_starting) { if (is_starting) { - TRY(stream.write_entire_buffer(DeprecatedString::formatted("\033[{};{};{}m{}{}{}", + TRY(stream.write_until_depleted(DeprecatedString::formatted("\033[{};{};{}m{}{}{}", style.bold() ? 1 : 22, style.underline() ? 4 : 24, style.italic() ? 3 : 23, style.background().to_vt_escape(), style.foreground().to_vt_escape(), style.hyperlink().to_vt_escape(true)) - .bytes())); + .bytes())); } else { - TRY(stream.write_entire_buffer(style.hyperlink().to_vt_escape(false).bytes())); + TRY(stream.write_until_depleted(style.hyperlink().to_vt_escape(false).bytes())); } return {}; @@ -1782,16 +1782,16 @@ ErrorOr VT::apply_style(Style const& style, Stream& stream, bool is_starti ErrorOr VT::clear_lines(size_t count_above, size_t count_below, Stream& stream) { if (count_below + count_above == 0) { - TRY(stream.write_entire_buffer("\033[2K"sv.bytes())); + TRY(stream.write_until_depleted("\033[2K"sv.bytes())); } else { // Go down count_below lines. if (count_below > 0) - TRY(stream.write_entire_buffer(DeprecatedString::formatted("\033[{}B", count_below).bytes())); + TRY(stream.write_until_depleted(DeprecatedString::formatted("\033[{}B", count_below).bytes())); // Then clear lines going upwards. for (size_t i = count_below + count_above; i > 0; --i) { - TRY(stream.write_entire_buffer("\033[2K"sv.bytes())); + TRY(stream.write_until_depleted("\033[2K"sv.bytes())); if (i != 1) - TRY(stream.write_entire_buffer("\033[A"sv.bytes())); + TRY(stream.write_until_depleted("\033[A"sv.bytes())); } } @@ -1800,17 +1800,17 @@ ErrorOr VT::clear_lines(size_t count_above, size_t count_below, Stream& st ErrorOr VT::save_cursor(Stream& stream) { - return stream.write_entire_buffer("\033[s"sv.bytes()); + return stream.write_until_depleted("\033[s"sv.bytes()); } ErrorOr VT::restore_cursor(Stream& stream) { - return stream.write_entire_buffer("\033[u"sv.bytes()); + return stream.write_until_depleted("\033[u"sv.bytes()); } ErrorOr VT::clear_to_end_of_line(Stream& stream) { - return stream.write_entire_buffer("\033[K"sv.bytes()); + return stream.write_until_depleted("\033[K"sv.bytes()); } enum VTState { diff --git a/Userland/Libraries/LibProtocol/Request.cpp b/Userland/Libraries/LibProtocol/Request.cpp index 44bcd7bdc2e..741ee08eed3 100644 --- a/Userland/Libraries/LibProtocol/Request.cpp +++ b/Userland/Libraries/LibProtocol/Request.cpp @@ -54,7 +54,7 @@ void Request::stream_into(Stream& stream) if (read_bytes.is_empty()) break; // FIXME: What do we do if this fails? - stream.write_entire_buffer(read_bytes).release_value_but_fixme_should_propagate_errors(); + stream.write_until_depleted(read_bytes).release_value_but_fixme_should_propagate_errors(); break; } while (true); diff --git a/Userland/Libraries/LibTLS/HandshakeClient.cpp b/Userland/Libraries/LibTLS/HandshakeClient.cpp index 7055531892e..f86b30af7e5 100644 --- a/Userland/Libraries/LibTLS/HandshakeClient.cpp +++ b/Userland/Libraries/LibTLS/HandshakeClient.cpp @@ -141,11 +141,11 @@ bool TLSv12::compute_master_secret_from_pre_master_secret(size_t length) if constexpr (TLS_SSL_KEYLOG_DEBUG) { auto file = MUST(Core::File::open("/home/anon/ssl_keylog"sv, Core::File::OpenMode::Append | Core::File::OpenMode::Write)); - MUST(file->write_entire_buffer("CLIENT_RANDOM "sv.bytes())); - MUST(file->write_entire_buffer(encode_hex({ m_context.local_random, 32 }).bytes())); - MUST(file->write_entire_buffer(" "sv.bytes())); - MUST(file->write_entire_buffer(encode_hex(m_context.master_key).bytes())); - MUST(file->write_entire_buffer("\n"sv.bytes())); + MUST(file->write_until_depleted("CLIENT_RANDOM "sv.bytes())); + MUST(file->write_until_depleted(encode_hex({ m_context.local_random, 32 }).bytes())); + MUST(file->write_until_depleted(" "sv.bytes())); + MUST(file->write_until_depleted(encode_hex(m_context.master_key).bytes())); + MUST(file->write_until_depleted("\n"sv.bytes())); } expand_key(); diff --git a/Userland/Libraries/LibTLS/Record.cpp b/Userland/Libraries/LibTLS/Record.cpp index d20a2633035..18a7f3b963c 100644 --- a/Userland/Libraries/LibTLS/Record.cpp +++ b/Userland/Libraries/LibTLS/Record.cpp @@ -146,9 +146,9 @@ void TLSv12::update_packet(ByteBuffer& packet) u64 seq_no = AK::convert_between_host_and_network_endian(m_context.local_sequence_number); u16 len = AK::convert_between_host_and_network_endian((u16)(packet.size() - header_size)); - MUST(aad_stream.write_value(seq_no)); // sequence number - MUST(aad_stream.write_entire_buffer(packet.bytes().slice(0, 3))); // content-type + version - MUST(aad_stream.write_value(len)); // length + MUST(aad_stream.write_value(seq_no)); // sequence number + MUST(aad_stream.write_until_depleted(packet.bytes().slice(0, 3))); // content-type + version + MUST(aad_stream.write_value(len)); // length VERIFY(MUST(aad_stream.tell()) == MUST(aad_stream.size())); // AEAD IV (12) @@ -387,9 +387,9 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer) u64 seq_no = AK::convert_between_host_and_network_endian(m_context.remote_sequence_number); u16 len = AK::convert_between_host_and_network_endian((u16)packet_length); - MUST(aad_stream.write_value(seq_no)); // sequence number - MUST(aad_stream.write_entire_buffer(buffer.slice(0, header_size - 2))); // content-type + version - MUST(aad_stream.write_value(len)); // length + MUST(aad_stream.write_value(seq_no)); // sequence number + MUST(aad_stream.write_until_depleted(buffer.slice(0, header_size - 2))); // content-type + version + MUST(aad_stream.write_value(len)); // length VERIFY(MUST(aad_stream.tell()) == MUST(aad_stream.size())); auto nonce = payload.slice(0, iv_length()); diff --git a/Userland/Libraries/LibWasm/Printer/Printer.cpp b/Userland/Libraries/LibWasm/Printer/Printer.cpp index 24bef8505bb..4f3ce671cf7 100644 --- a/Userland/Libraries/LibWasm/Printer/Printer.cpp +++ b/Userland/Libraries/LibWasm/Printer/Printer.cpp @@ -34,7 +34,7 @@ Optional instruction_from_name(StringView name) void Printer::print_indent() { for (size_t i = 0; i < m_indent; ++i) - m_stream.write_entire_buffer(" "sv.bytes()).release_value_but_fixme_should_propagate_errors(); + m_stream.write_until_depleted(" "sv.bytes()).release_value_but_fixme_should_propagate_errors(); } void Printer::print(Wasm::BlockType const& type) diff --git a/Userland/Libraries/LibWasm/Printer/Printer.h b/Userland/Libraries/LibWasm/Printer/Printer.h index d977d9d8bbf..760e2533829 100644 --- a/Userland/Libraries/LibWasm/Printer/Printer.h +++ b/Userland/Libraries/LibWasm/Printer/Printer.h @@ -68,7 +68,7 @@ private: { StringBuilder builder; builder.appendff(fmt.view(), forward(args)...); - m_stream.write_entire_buffer(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors(); + m_stream.write_until_depleted(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors(); } Stream& m_stream; diff --git a/Userland/Libraries/LibWebSocket/Impl/WebSocketImplSerenity.cpp b/Userland/Libraries/LibWebSocket/Impl/WebSocketImplSerenity.cpp index 09d093a6154..2becc2a4063 100644 --- a/Userland/Libraries/LibWebSocket/Impl/WebSocketImplSerenity.cpp +++ b/Userland/Libraries/LibWebSocket/Impl/WebSocketImplSerenity.cpp @@ -22,7 +22,7 @@ bool WebSocketImplSerenity::can_read_line() bool WebSocketImplSerenity::send(ReadonlyBytes bytes) { - return !m_socket->write_entire_buffer(bytes).is_error(); + return !m_socket->write_until_depleted(bytes).is_error(); } bool WebSocketImplSerenity::eof() diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index f5082c7de00..09ddfd69565 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -1823,7 +1823,7 @@ ErrorOr Execute::for_each_entry(RefPtr shell, Function decompress_file(NonnullOwnPtr input_stream, Str auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); while (!gzip_stream.is_eof()) { auto span = TRY(gzip_stream.read_some(buffer)); - TRY(output_stream.write_entire_buffer(span)); + TRY(output_stream.write_until_depleted(span)); } return {}; diff --git a/Userland/Utilities/gzip.cpp b/Userland/Utilities/gzip.cpp index 28fbdc38c20..4b12a7b5f75 100644 --- a/Userland/Utilities/gzip.cpp +++ b/Userland/Utilities/gzip.cpp @@ -57,7 +57,7 @@ ErrorOr serenity_main(Main::Arguments arguments) output_bytes = TRY(Compress::GzipCompressor::compress_all(input_bytes)); auto output_stream = write_to_stdout ? TRY(Core::File::standard_output()) : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write)); - TRY(output_stream->write_entire_buffer(output_bytes)); + TRY(output_stream->write_until_depleted(output_bytes)); if (!keep_input_files) { TRY(Core::System::unlink(input_filename)); diff --git a/Userland/Utilities/icc.cpp b/Userland/Utilities/icc.cpp index cc3279abd03..ba85c844038 100644 --- a/Userland/Utilities/icc.cpp +++ b/Userland/Utilities/icc.cpp @@ -145,7 +145,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!dump_out_path.is_empty()) { auto output_stream = TRY(Core::File::open(dump_out_path, Core::File::OpenMode::Write)); - TRY(output_stream->write_entire_buffer(icc_bytes)); + TRY(output_stream->write_until_depleted(icc_bytes)); } return Gfx::ICC::Profile::try_load_from_externally_owned_memory(icc_bytes); }()); @@ -153,7 +153,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!reencode_out_path.is_empty()) { auto reencoded_bytes = TRY(Gfx::ICC::encode(profile)); auto output_stream = TRY(Core::File::open(reencode_out_path, Core::File::OpenMode::Write)); - TRY(output_stream->write_entire_buffer(reencoded_bytes)); + TRY(output_stream->write_until_depleted(reencoded_bytes)); } bool do_print = (dump_out_path.is_empty() && reencode_out_path.is_empty()) || force_print; diff --git a/Userland/Utilities/image.cpp b/Userland/Utilities/image.cpp index 2d93854d393..134455871d8 100644 --- a/Userland/Utilities/image.cpp +++ b/Userland/Utilities/image.cpp @@ -56,7 +56,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto output_stream = TRY(Core::File::open(out_path, Core::File::OpenMode::Write)); - TRY(output_stream->write_entire_buffer(bytes)); + TRY(output_stream->write_until_depleted(bytes)); return 0; }