mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Rename Stream::write_entire_buffer to Stream::write_until_depleted
No functional changes.
This commit is contained in:
parent
a3f73e7d85
commit
ecd1862859
Notes:
sideshowbarker
2024-07-18 00:34:07 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/ecd1862859 Pull-request: https://github.com/SerenityOS/serenity/pull/17684 Reviewed-by: https://github.com/JanDeVisser ✅ Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/linusg ✅
46 changed files with 141 additions and 141 deletions
|
@ -34,7 +34,7 @@ public:
|
|||
return m_stream->read_some(bytes);
|
||||
}
|
||||
virtual ErrorOr<size_t> write_some(ReadonlyBytes bytes) override { return m_stream->write_some(bytes); }
|
||||
virtual ErrorOr<void> write_entire_buffer(ReadonlyBytes bytes) override { return m_stream->write_entire_buffer(bytes); }
|
||||
virtual ErrorOr<void> 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<size_t> write_some(ReadonlyBytes bytes) override { return m_stream->write_some(bytes); }
|
||||
virtual ErrorOr<void> write_entire_buffer(ReadonlyBytes bytes) override { return m_stream->write_entire_buffer(bytes); }
|
||||
virtual ErrorOr<void> 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
|
||||
|
|
|
@ -89,7 +89,7 @@ ErrorOr<size_t> FixedMemoryStream::write_some(ReadonlyBytes bytes)
|
|||
return nwritten;
|
||||
}
|
||||
|
||||
ErrorOr<void> FixedMemoryStream::write_entire_buffer(ReadonlyBytes bytes)
|
||||
ErrorOr<void> 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);
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
virtual ErrorOr<size_t> seek(i64 offset, SeekMode seek_mode = SeekMode::SetPosition) override;
|
||||
|
||||
virtual ErrorOr<size_t> write_some(ReadonlyBytes bytes) override;
|
||||
virtual ErrorOr<void> write_entire_buffer(ReadonlyBytes bytes) override;
|
||||
virtual ErrorOr<void> write_until_depleted(ReadonlyBytes bytes) override;
|
||||
|
||||
Bytes bytes();
|
||||
ReadonlyBytes bytes() const;
|
||||
|
|
|
@ -78,7 +78,7 @@ ErrorOr<void> Stream::discard(size_t discarded_bytes)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> Stream::write_entire_buffer(ReadonlyBytes buffer)
|
||||
ErrorOr<void> Stream::write_until_depleted(ReadonlyBytes buffer)
|
||||
{
|
||||
size_t nwritten = 0;
|
||||
while (nwritten < buffer.size()) {
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
virtual ErrorOr<size_t> 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<void> write_entire_buffer(ReadonlyBytes);
|
||||
virtual ErrorOr<void> write_until_depleted(ReadonlyBytes);
|
||||
|
||||
template<typename T>
|
||||
requires(requires(Stream& stream) { { T::read_from_stream(stream) } -> SameAs<ErrorOr<T>>; })
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
requires(Traits<T>::is_trivially_serializable())
|
||||
ErrorOr<void> 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,
|
||||
|
|
|
@ -796,7 +796,7 @@ ErrorOr<void> Ext2FSInode::write_directory(Vector<Ext2FSDirectoryEntry>& entries
|
|||
MUST(stream.write_value<u16>(entry.record_length));
|
||||
MUST(stream.write_value<u8>(entry.name->length()));
|
||||
MUST(stream.write_value<u8>(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<u8>(0));
|
||||
|
|
|
@ -249,7 +249,7 @@ ErrorOr<size_t> OpenFileDescription::get_dir_entries(UserOrKernelBuffer& output_
|
|||
MUST(stream.write_value<u64>(entry.inode.index().value()));
|
||||
MUST(stream.write_value(m_inode->fs().internal_file_type_to_directory_entry_type(entry)));
|
||||
MUST(stream.write_value<u32>(entry.name.length()));
|
||||
MUST(stream.write_entire_buffer(entry.name.bytes()));
|
||||
MUST(stream.write_until_depleted(entry.name.bytes()));
|
||||
return {};
|
||||
});
|
||||
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<size_t, TestResult> const& result_map, Vector<Deprec
|
|||
complete_results.set("duration", time_taken_in_ms / 1000.);
|
||||
complete_results.set("results", result_object);
|
||||
|
||||
if (file->write_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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ ErrorOr<void> Image::export_bmp_to_file(NonnullOwnPtr<Stream> 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<void> Image::export_png_to_file(NonnullOwnPtr<Stream> 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<void> Image::export_qoi_to_file(NonnullOwnPtr<Stream> 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 {};
|
||||
}
|
||||
|
||||
|
|
|
@ -793,7 +793,7 @@ ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::File> 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 {};
|
||||
}
|
||||
|
||||
|
|
|
@ -248,8 +248,8 @@ ErrorOr<Vector<Color>> PaletteWidget::load_palette_path(DeprecatedString const&
|
|||
ErrorOr<void> PaletteWidget::save_palette_file(Vector<Color> palette, NonnullOwnPtr<Core::File> 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 {};
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ ErrorOr<void> 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") {
|
||||
|
|
|
@ -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 {};
|
||||
}
|
||||
|
||||
|
|
|
@ -1807,7 +1807,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> 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"
|
||||
|
|
|
@ -135,7 +135,7 @@ ErrorOr<void> 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",
|
||||
|
|
|
@ -42,7 +42,7 @@ static ErrorOr<void> 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 {};
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -70,10 +70,10 @@ int main(int argc, char** argv, char** env)
|
|||
profile_strings = make<Vector<NonnullOwnPtr<DeprecatedString>>>();
|
||||
profile_string_id_map = make<Vector<int>>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -154,9 +154,9 @@ ErrorOr<void> 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<void> 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<u8, block_size> 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<void> 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<void> TarOutputStream::finish()
|
|||
VERIFY(!m_finished);
|
||||
constexpr Array<u8, block_size> 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 {};
|
||||
}
|
||||
|
|
|
@ -60,10 +60,10 @@ struct [[gnu::packed]] EndOfCentralDirectory {
|
|||
ErrorOr<void> 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<void> 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<void> 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 {};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -325,7 +325,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_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<void> DeflateCompressor::flush()
|
|||
TRY(m_output_stream->write_bits(0b00u, 2)); // no compression
|
||||
TRY(m_output_stream->align_to_byte_boundary());
|
||||
LittleEndian<u16> len = m_pending_block_size;
|
||||
TRY(m_output_stream->write_entire_buffer(len.bytes()));
|
||||
TRY(m_output_stream->write_until_depleted(len.bytes()));
|
||||
LittleEndian<u16> 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<ByteBuffer> DeflateCompressor::compress_all(ReadonlyBytes bytes, Compres
|
|||
auto output_stream = TRY(try_make<AllocatingMemoryStream>());
|
||||
auto deflate_stream = TRY(DeflateCompressor::construct(MaybeOwned<Stream>(*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()));
|
||||
|
|
|
@ -175,7 +175,7 @@ ErrorOr<ByteBuffer> 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<size_t> 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<u32> digest = crc32.digest();
|
||||
LittleEndian<u32> 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<ByteBuffer> GzipCompressor::compress_all(ReadonlyBytes bytes)
|
|||
auto output_stream = TRY(try_make<AllocatingMemoryStream>());
|
||||
GzipCompressor gzip_stream { MaybeOwned<Stream>(*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()));
|
||||
|
|
|
@ -168,7 +168,7 @@ ErrorOr<ByteBuffer> ZlibCompressor::compress_all(ReadonlyBytes bytes, ZlibCompre
|
|||
auto output_stream = TRY(try_make<AllocatingMemoryStream>());
|
||||
auto zlib_stream = TRY(ZlibCompressor::construct(MaybeOwned<Stream>(*output_stream), compression_level));
|
||||
|
||||
TRY(zlib_stream->write_entire_buffer(bytes));
|
||||
TRY(zlib_stream->write_until_depleted(bytes));
|
||||
|
||||
TRY(zlib_stream->finish());
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ ErrorOr<void> 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<void> 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 {};
|
||||
|
|
|
@ -81,7 +81,7 @@ ErrorOr<void> Name::write_to_stream(Stream& stream) const
|
|||
auto parts = as_string().split_view('.');
|
||||
for (auto& part : parts) {
|
||||
TRY(stream.write_value<u8>(part.length()));
|
||||
TRY(stream.write_entire_buffer(part.bytes()));
|
||||
TRY(stream.write_until_depleted(part.bytes()));
|
||||
}
|
||||
TRY(stream.write_value('\0'));
|
||||
return {};
|
||||
|
|
|
@ -67,7 +67,7 @@ ErrorOr<ByteBuffer> 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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -267,7 +267,7 @@ ErrorOr<ByteBuffer> 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()));
|
||||
|
||||
|
|
|
@ -259,10 +259,10 @@ ErrorOr<void> 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 {};
|
||||
}
|
||||
|
|
|
@ -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); });
|
||||
|
||||
|
|
|
@ -606,7 +606,7 @@ ErrorOr<void> 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<void> 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) -> Result<DeprecatedString
|
|||
auto stderr_stream = Core::File::standard_error().release_value_but_fixme_should_propagate_errors();
|
||||
auto prompt_lines = max(current_prompt_metrics().line_metrics.size(), 1ul) - 1;
|
||||
for (size_t i = 0; i < prompt_lines; ++i)
|
||||
stderr_stream->write_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<int>(prompt_lines), 0, *stderr_stream).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
@ -1375,13 +1375,13 @@ ErrorOr<void> 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<void> 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<void> 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<void> 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<void> Editor::reposition_cursor(Stream& stream, bool to_end)
|
|||
|
||||
ErrorOr<void> 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<void> VT::move_relative(int row, int col, Stream& stream)
|
||||
|
@ -1623,9 +1623,9 @@ ErrorOr<void> 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<void> 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<void> VT::apply_style(Style const& style, Stream& stream, bool is_starti
|
|||
ErrorOr<void> 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<void> VT::clear_lines(size_t count_above, size_t count_below, Stream& st
|
|||
|
||||
ErrorOr<void> VT::save_cursor(Stream& stream)
|
||||
{
|
||||
return stream.write_entire_buffer("\033[s"sv.bytes());
|
||||
return stream.write_until_depleted("\033[s"sv.bytes());
|
||||
}
|
||||
|
||||
ErrorOr<void> VT::restore_cursor(Stream& stream)
|
||||
{
|
||||
return stream.write_entire_buffer("\033[u"sv.bytes());
|
||||
return stream.write_until_depleted("\033[u"sv.bytes());
|
||||
}
|
||||
|
||||
ErrorOr<void> 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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -34,7 +34,7 @@ Optional<OpCode> 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)
|
||||
|
|
|
@ -68,7 +68,7 @@ private:
|
|||
{
|
||||
StringBuilder builder;
|
||||
builder.appendff(fmt.view(), forward<Args>(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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -1823,7 +1823,7 @@ ErrorOr<void> Execute::for_each_entry(RefPtr<Shell> shell, Function<ErrorOr<Iter
|
|||
break;
|
||||
|
||||
should_enable_notifier = true;
|
||||
stream.write_entire_buffer({ buffer, (size_t)read_size }).release_value_but_fixme_should_propagate_errors();
|
||||
stream.write_until_depleted({ buffer, (size_t)read_size }).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
loop.quit(NothingLeft);
|
||||
|
|
|
@ -18,7 +18,7 @@ static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::File> 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 {};
|
||||
|
|
|
@ -57,7 +57,7 @@ ErrorOr<int> 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));
|
||||
|
|
|
@ -145,7 +145,7 @@ ErrorOr<int> 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<int> 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;
|
||||
|
|
|
@ -56,7 +56,7 @@ ErrorOr<int> 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue