summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/cat.cpp2
-rw-r--r--Userland/Utilities/checksum.cpp6
-rw-r--r--Userland/Utilities/cksum.cpp4
-rw-r--r--Userland/Utilities/cmp.cpp4
-rw-r--r--Userland/Utilities/file.cpp2
-rw-r--r--Userland/Utilities/gml-format.cpp3
-rw-r--r--Userland/Utilities/gunzip.cpp2
-rw-r--r--Userland/Utilities/headless-browser.cpp3
-rw-r--r--Userland/Utilities/hexdump.cpp2
-rw-r--r--Userland/Utilities/js.cpp3
-rw-r--r--Userland/Utilities/nc.cpp3
-rw-r--r--Userland/Utilities/pro.cpp6
-rw-r--r--Userland/Utilities/reboot.cpp3
-rw-r--r--Userland/Utilities/sed.cpp5
-rw-r--r--Userland/Utilities/shot.cpp3
-rw-r--r--Userland/Utilities/shutdown.cpp3
-rw-r--r--Userland/Utilities/strace.cpp3
-rw-r--r--Userland/Utilities/strings.cpp2
-rw-r--r--Userland/Utilities/sysctl.cpp3
-rw-r--r--Userland/Utilities/tail.cpp3
-rw-r--r--Userland/Utilities/tar.cpp4
-rw-r--r--Userland/Utilities/uniq.cpp5
-rw-r--r--Userland/Utilities/uptime.cpp2
-rw-r--r--Userland/Utilities/utmpupdate.cpp3
-rw-r--r--Userland/Utilities/wasm.cpp23
25 files changed, 61 insertions, 41 deletions
diff --git a/Userland/Utilities/cat.cpp b/Userland/Utilities/cat.cpp
index 0905a03352..237ba67f14 100644
--- a/Userland/Utilities/cat.cpp
+++ b/Userland/Utilities/cat.cpp
@@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Array<u8, 32768> buffer;
for (auto const& file : files) {
while (!file->is_eof()) {
- auto const buffer_span = TRY(file->read(buffer));
+ auto const buffer_span = TRY(file->read_some(buffer));
out("{:s}", buffer_span);
}
}
diff --git a/Userland/Utilities/checksum.cpp b/Userland/Utilities/checksum.cpp
index 78cf79ef5b..d5386d6c62 100644
--- a/Userland/Utilities/checksum.cpp
+++ b/Userland/Utilities/checksum.cpp
@@ -66,13 +66,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Array<u8, PAGE_SIZE> buffer;
if (!verify_from_paths) {
while (!file->is_eof())
- hash.update(TRY(file->read(buffer)));
+ hash.update(TRY(file->read_some(buffer)));
outln("{:hex-dump} {}", hash.digest().bytes(), path);
} else {
StringBuilder checksum_list_contents;
Array<u8, 1> checksum_list_buffer;
while (!file->is_eof())
- checksum_list_contents.append(TRY(file->read(checksum_list_buffer)).data()[0]);
+ checksum_list_contents.append(TRY(file->read_some(checksum_list_buffer)).data()[0]);
Vector<StringView> const lines = checksum_list_contents.string_view().split_view("\n"sv);
for (size_t i = 0; i < lines.size(); ++i) {
@@ -96,7 +96,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto file_from_filename = file_from_filename_or_error.release_value();
hash.reset();
while (!file_from_filename->is_eof())
- hash.update(TRY(file_from_filename->read(buffer)));
+ hash.update(TRY(file_from_filename->read_some(buffer)));
if (DeprecatedString::formatted("{:hex-dump}", hash.digest().bytes()) == line[0])
outln("{}: OK", filename);
else {
diff --git a/Userland/Utilities/cksum.cpp b/Userland/Utilities/cksum.cpp
index e0c10a85d3..df389427ba 100644
--- a/Userland/Utilities/cksum.cpp
+++ b/Userland/Utilities/cksum.cpp
@@ -59,7 +59,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (algorithm == "crc32") {
Crypto::Checksum::CRC32 crc32;
while (!file->is_eof()) {
- auto data_or_error = file->read(buffer);
+ auto data_or_error = file->read_some(buffer);
if (data_or_error.is_error()) {
warnln("{}: Failed to read {}: {}", arguments.strings[0], filepath, data_or_error.error());
fail = true;
@@ -72,7 +72,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} else if (algorithm == "adler32") {
Crypto::Checksum::Adler32 adler32;
while (!file->is_eof()) {
- auto data_or_error = file->read(buffer);
+ auto data_or_error = file->read_some(buffer);
if (data_or_error.is_error()) {
warnln("{}: Failed to read {}: {}", arguments.strings[0], filepath, data_or_error.error());
fail = true;
diff --git a/Userland/Utilities/cmp.cpp b/Userland/Utilities/cmp.cpp
index 426fb4151e..0ceea7f6e1 100644
--- a/Userland/Utilities/cmp.cpp
+++ b/Userland/Utilities/cmp.cpp
@@ -75,8 +75,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
while (true) {
- TRY(file1->read(buffer1));
- TRY(file2->read(buffer2));
+ TRY(file1->read_some(buffer1));
+ TRY(file2->read_some(buffer2));
if (file1->is_eof() && file2->is_eof())
break;
diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp
index 53279930a1..c574e1f20a 100644
--- a/Userland/Utilities/file.cpp
+++ b/Userland/Utilities/file.cpp
@@ -187,7 +187,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} else if (!file_size_in_bytes) {
outln("{}: empty", path);
} else {
- auto bytes = TRY(file->read(buffer));
+ auto bytes = TRY(file->read_some(buffer));
auto file_name_guess = Core::guess_mime_type_based_on_filename(path);
auto mime_type = Core::guess_mime_type_based_on_sniffed_bytes(bytes).value_or(file_name_guess);
auto human_readable_description = get_description_from_mime_type(mime_type, path).value_or(mime_type);
diff --git a/Userland/Utilities/gml-format.cpp b/Userland/Utilities/gml-format.cpp
index ef90964249..465573d722 100644
--- a/Userland/Utilities/gml-format.cpp
+++ b/Userland/Utilities/gml-format.cpp
@@ -28,7 +28,8 @@ static ErrorOr<bool> format_file(StringView path, bool inplace)
return true;
TRY(file->seek(0, SeekMode::SetPosition));
TRY(file->truncate(0));
- TRY(file->write(formatted_gml.bytes()));
+ // FIXME: This should write the entire span.
+ TRY(file->write_some(formatted_gml.bytes()));
} else {
out("{}", formatted_gml);
}
diff --git a/Userland/Utilities/gunzip.cpp b/Userland/Utilities/gunzip.cpp
index a0fb4048a7..d04a8e9036 100644
--- a/Userland/Utilities/gunzip.cpp
+++ b/Userland/Utilities/gunzip.cpp
@@ -17,7 +17,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(buffer));
+ auto span = TRY(gzip_stream.read_some(buffer));
TRY(output_stream.write_entire_buffer(span));
}
diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp
index 5e62428333..7453120887 100644
--- a/Userland/Utilities/headless-browser.cpp
+++ b/Userland/Utilities/headless-browser.cpp
@@ -174,7 +174,8 @@ static ErrorOr<NonnullRefPtr<Core::Timer>> load_page_for_screenshot_and_exit(Cor
auto output_file = MUST(Core::File::open(output_file_path, Core::File::OpenMode::Write));
auto image_buffer = MUST(Gfx::PNGWriter::encode(*screenshot));
- MUST(output_file->write(image_buffer.bytes()));
+ // FIXME: This should write the entire buffer.
+ MUST(output_file->write_some(image_buffer.bytes()));
} else {
warnln("No screenshot available");
}
diff --git a/Userland/Utilities/hexdump.cpp b/Userland/Utilities/hexdump.cpp
index e27c2d2362..67e4f20b2c 100644
--- a/Userland/Utilities/hexdump.cpp
+++ b/Userland/Utilities/hexdump.cpp
@@ -86,7 +86,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
}
bytes = contents.span().slice(0, bytes_to_read);
- bytes = TRY(file->read(bytes));
+ bytes = TRY(file->read_some(bytes));
total_bytes_read += bytes.size();
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 7a08f4beec..db9fae8d59 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -188,7 +188,8 @@ static ErrorOr<void> write_to_file(String const& path)
for (size_t i = 0; i < g_repl_statements.size(); i++) {
auto line = g_repl_statements[i].bytes();
if (line.size() > 0 && i != g_repl_statements.size() - 1) {
- TRY(file->write(line));
+ // FIXME: This should write the entire span.
+ TRY(file->write_some(line));
}
if (i != g_repl_statements.size() - 1) {
TRY(file->write_value('\n'));
diff --git a/Userland/Utilities/nc.cpp b/Userland/Utilities/nc.cpp
index 6d51312e5c..858bbed77d 100644
--- a/Userland/Utilities/nc.cpp
+++ b/Userland/Utilities/nc.cpp
@@ -82,7 +82,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto nread = TRY(Core::System::read(STDIN_FILENO, buffer_span));
buffer_span = buffer_span.trim(nread);
- TRY(socket->write({ buffer_span.data(), static_cast<size_t>(nread) }));
+ // FIXME: This should write the entire span.
+ TRY(socket->write_some({ buffer_span.data(), static_cast<size_t>(nread) }));
}
}
diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp
index ba363711dc..5202296dad 100644
--- a/Userland/Utilities/pro.cpp
+++ b/Userland/Utilities/pro.cpp
@@ -112,18 +112,18 @@ public:
{
}
- virtual ErrorOr<Bytes> read(Bytes) override
+ virtual ErrorOr<Bytes> read_some(Bytes) override
{
return Error::from_errno(EBADF);
}
- virtual ErrorOr<size_t> write(ReadonlyBytes bytes) override
+ virtual ErrorOr<size_t> write_some(ReadonlyBytes bytes) override
{
// Pretend that we wrote the whole buffer if the condition is untrue.
if (!m_condition())
return bytes.size();
- return m_stream->write(bytes);
+ return m_stream->write_some(bytes);
}
virtual bool is_eof() const override
diff --git a/Userland/Utilities/reboot.cpp b/Userland/Utilities/reboot.cpp
index cd819bdb47..462e2e0111 100644
--- a/Userland/Utilities/reboot.cpp
+++ b/Userland/Utilities/reboot.cpp
@@ -14,7 +14,8 @@ ErrorOr<int> serenity_main(Main::Arguments)
auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
const DeprecatedString file_contents = "1";
- TRY(file->write(file_contents.bytes()));
+ // FIXME: This should write the entire span.
+ TRY(file->write_some(file_contents.bytes()));
file->close();
return 0;
diff --git a/Userland/Utilities/sed.cpp b/Userland/Utilities/sed.cpp
index abb1057204..a978896bc7 100644
--- a/Userland/Utilities/sed.cpp
+++ b/Userland/Utilities/sed.cpp
@@ -141,8 +141,9 @@ ErrorOr<int> serenity_main(Main::Arguments args)
if (maybe_output_file.has_value()) {
auto const& output_file = maybe_output_file.value();
- TRY(output_file->write(result.bytes()));
- TRY(output_file->write("\n"sv.bytes()));
+ // FIXME: This should write the entire span.
+ TRY(output_file->write_some(result.bytes()));
+ TRY(output_file->write_some("\n"sv.bytes()));
}
}
}
diff --git a/Userland/Utilities/shot.cpp b/Userland/Utilities/shot.cpp
index 0848130391..78e3c4db83 100644
--- a/Userland/Utilities/shot.cpp
+++ b/Userland/Utilities/shot.cpp
@@ -167,7 +167,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
auto& file = *file_or_error.value();
- TRY(file.write(encoded_bitmap.bytes()));
+ // FIXME: This should write the entire span.
+ TRY(file.write_some(encoded_bitmap.bytes()));
if (edit_image)
TRY(Core::Process::spawn("/bin/PixelPaint"sv, Array { output_path }));
diff --git a/Userland/Utilities/shutdown.cpp b/Userland/Utilities/shutdown.cpp
index 432d59b251..2547de06a5 100644
--- a/Userland/Utilities/shutdown.cpp
+++ b/Userland/Utilities/shutdown.cpp
@@ -18,7 +18,8 @@ ErrorOr<int> serenity_main(Main::Arguments)
auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
const DeprecatedString file_contents = "2";
- TRY(file->write(file_contents.bytes()));
+ // FIXME: This should write the entire span.
+ TRY(file->write_some(file_contents.bytes()));
file->close();
return 0;
diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp
index 1b285d0f39..e1afa0e22b 100644
--- a/Userland/Utilities/strace.cpp
+++ b/Userland/Utilities/strace.cpp
@@ -932,6 +932,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
FormattedSyscallBuilder builder(syscall_name);
TRY(format_syscall(builder, syscall_function, arg1, arg2, arg3, res));
- TRY(trace_file->write(builder.string_view().bytes()));
+ // FIXME: This should write the entire span.
+ TRY(trace_file->write_some(builder.string_view().bytes()));
}
}
diff --git a/Userland/Utilities/strings.cpp b/Userland/Utilities/strings.cpp
index 8f1f0ab7d2..326b826df9 100644
--- a/Userland/Utilities/strings.cpp
+++ b/Userland/Utilities/strings.cpp
@@ -72,7 +72,7 @@ static ErrorOr<void> process_strings_in_file(StringView path, bool show_paths, S
size_t string_offset_position = 0;
bool did_show_path = false;
while (!file->is_eof()) {
- auto buffer_span = TRY(file->read(buffer));
+ auto buffer_span = TRY(file->read_some(buffer));
while (!buffer_span.is_empty()) {
string_offset_position += processed_characters;
processed_characters = process_characters_in_span(output_characters, buffer_span);
diff --git a/Userland/Utilities/sysctl.cpp b/Userland/Utilities/sysctl.cpp
index 10b4e9ec95..90d587ed6c 100644
--- a/Userland/Utilities/sysctl.cpp
+++ b/Userland/Utilities/sysctl.cpp
@@ -48,7 +48,8 @@ static bool write_variable(StringView name, StringView value)
warnln("Failed to open {}: {}", path, file.error());
return false;
}
- if (auto result = file.value()->write(value.bytes()); result.is_error()) {
+ // FIXME: This should write the entire span.
+ if (auto result = file.value()->write_some(value.bytes()); result.is_error()) {
warnln("Failed to write {}: {}", path, result.error());
return false;
}
diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp
index 687654ce1f..3e73b69cd4 100644
--- a/Userland/Utilities/tail.cpp
+++ b/Userland/Utilities/tail.cpp
@@ -35,7 +35,8 @@ static ErrorOr<off_t> find_seek_pos(Core::File& file, int wanted_lines)
if (file.is_eof())
break;
Array<u8, 1> buffer;
- auto ch = TRY(file.read(buffer));
+ // FIXME: This should read the entire span.
+ auto ch = TRY(file.read_some(buffer));
if (*ch.data() == '\n' && (end - pos) > 1) {
lines++;
if (lines == wanted_lines)
diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp
index 6d2cbb19cb..ae8b9352fc 100644
--- a/Userland/Utilities/tar.cpp
+++ b/Userland/Utilities/tar.cpp
@@ -127,7 +127,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Array<u8, buffer_size> buffer;
while (!file_stream.is_eof()) {
- auto slice = TRY(file_stream.read(buffer));
+ auto slice = TRY(file_stream.read_some(buffer));
long_name.append(reinterpret_cast<char*>(slice.data()), slice.size());
}
@@ -162,7 +162,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Array<u8, buffer_size> buffer;
while (!file_stream.is_eof()) {
- auto slice = TRY(file_stream.read(buffer));
+ auto slice = TRY(file_stream.read_some(buffer));
TRY(Core::System::write(fd, slice));
}
diff --git a/Userland/Utilities/uniq.cpp b/Userland/Utilities/uniq.cpp
index d4826a3342..7253c5924d 100644
--- a/Userland/Utilities/uniq.cpp
+++ b/Userland/Utilities/uniq.cpp
@@ -17,10 +17,11 @@ static ErrorOr<void> write_line_content(StringView line, size_t count, bool dupl
if (duplicates_only && count <= 1)
return {};
+ // FIXME: This should write the entire span.
if (print_count)
- TRY(outfile.write(DeprecatedString::formatted("{} {}\n", count, line).bytes()));
+ TRY(outfile.write_some(DeprecatedString::formatted("{} {}\n", count, line).bytes()));
else
- TRY(outfile.write(DeprecatedString::formatted("{}\n", line).bytes()));
+ TRY(outfile.write_some(DeprecatedString::formatted("{}\n", line).bytes()));
return {};
}
diff --git a/Userland/Utilities/uptime.cpp b/Userland/Utilities/uptime.cpp
index ee0f65ec34..e289eb5517 100644
--- a/Userland/Utilities/uptime.cpp
+++ b/Userland/Utilities/uptime.cpp
@@ -19,7 +19,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
TRY(Core::System::pledge("stdio"));
Array<u8, BUFSIZ> buffer;
- auto read_buffer = TRY(file->read(buffer));
+ auto read_buffer = TRY(file->read_some(buffer));
auto maybe_seconds = AK::StringUtils::convert_to_uint(StringView(read_buffer));
if (!maybe_seconds.has_value())
return Error::from_string_literal("Couldn't convert to number");
diff --git a/Userland/Utilities/utmpupdate.cpp b/Userland/Utilities/utmpupdate.cpp
index 381e5573b9..be2ec0334d 100644
--- a/Userland/Utilities/utmpupdate.cpp
+++ b/Userland/Utilities/utmpupdate.cpp
@@ -72,7 +72,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(file->seek(0, SeekMode::SetPosition));
TRY(file->truncate(0));
- TRY(file->write(json.to_deprecated_string().bytes()));
+ // FIXME: This should write the entire span.
+ TRY(file->write_some(json.to_deprecated_string().bytes()));
return 0;
}
diff --git a/Userland/Utilities/wasm.cpp b/Userland/Utilities/wasm.cpp
index e02e6dd748..b4f6f0c046 100644
--- a/Userland/Utilities/wasm.cpp
+++ b/Userland/Utilities/wasm.cpp
@@ -53,12 +53,14 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi
if (always_print_stack)
config.dump_stack();
if (always_print_instruction) {
- g_stdout->write(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
+ // FIXME: This should write the entire span.
+ g_stdout->write_some(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
g_printer->print(instr);
}
if (g_continue)
return true;
- g_stdout->write(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
+ // FIXME: This should write the entire span.
+ g_stdout->write_some(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
g_printer->print(instr);
DeprecatedString last_command = "";
for (;;) {
@@ -214,7 +216,8 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi
if (!result.values().is_empty())
warnln("Returned:");
for (auto& value : result.values()) {
- g_stdout->write(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
+ // FIXME: This should write the entire span.
+ g_stdout->write_some(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
g_printer->print(value);
}
}
@@ -454,15 +457,18 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto print_func = [&](auto const& address) {
Wasm::FunctionInstance* fn = machine.store().get(address);
- g_stdout->write(DeprecatedString::formatted("- Function with address {}, ptr = {}\n", address.value(), fn).bytes()).release_value_but_fixme_should_propagate_errors();
+ // FIXME: This should write the entire span.
+ g_stdout->write_some(DeprecatedString::formatted("- Function with address {}, ptr = {}\n", address.value(), fn).bytes()).release_value_but_fixme_should_propagate_errors();
if (fn) {
- g_stdout->write(DeprecatedString::formatted(" wasm function? {}\n", fn->has<Wasm::WasmFunction>()).bytes()).release_value_but_fixme_should_propagate_errors();
+ // FIXME: This should write the entire span.
+ g_stdout->write_some(DeprecatedString::formatted(" wasm function? {}\n", fn->has<Wasm::WasmFunction>()).bytes()).release_value_but_fixme_should_propagate_errors();
fn->visit(
[&](Wasm::WasmFunction const& func) {
Wasm::Printer printer { *g_stdout, 3 };
- g_stdout->write(" type:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
+ // FIXME: This should write the entire span.
+ g_stdout->write_some(" type:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
printer.print(func.type());
- g_stdout->write(" code:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
+ g_stdout->write_some(" code:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
printer.print(func.code());
},
[](Wasm::HostFunction const&) {});
@@ -526,7 +532,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!result.values().is_empty())
warnln("Returned:");
for (auto& value : result.values()) {
- g_stdout->write(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
+ // FIXME: This should write the entire span.
+ g_stdout->write_some(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
g_printer->print(value);
}
}