mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:47:35 +00:00
LibCore: Rename Stream::read_all
to read_until_eof
This generally seems like a better name, especially if we somehow also need a better name for "read the entire buffer, but not the entire file" somewhere down the line.
This commit is contained in:
parent
5061a905ff
commit
ed4c2f2f8e
65 changed files with 88 additions and 88 deletions
|
@ -90,7 +90,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (!flag_set && !flag_delete) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/arp"sv, Core::Stream::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
Vector<JsonValue> sorted_regions = json.as_array().values();
|
||||
|
|
|
@ -23,7 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(filepath, Core::Stream::OpenMode::Read));
|
||||
ByteBuffer buffer = TRY(file->read_all());
|
||||
ByteBuffer buffer = TRY(file->read_until_eof());
|
||||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
|
|||
} else if (text.is_empty()) {
|
||||
// Copy our stdin.
|
||||
auto c_stdin = TRY(Core::Stream::File::standard_input());
|
||||
auto buffer = TRY(c_stdin->read_all());
|
||||
auto buffer = TRY(c_stdin->read_until_eof());
|
||||
dbgln("Read size {}", buffer.size());
|
||||
dbgln("Read data: `{}`", StringView(buffer.bytes()));
|
||||
options.data = buffer.bytes();
|
||||
|
|
|
@ -18,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto content = TRY(file->read_all());
|
||||
auto content = TRY(file->read_until_eof());
|
||||
StringView content_view(content);
|
||||
|
||||
Cpp::Lexer lexer(content);
|
||||
|
|
|
@ -21,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (path.is_empty())
|
||||
path = "Source/little/main.cpp"sv;
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto content = TRY(file->read_all());
|
||||
auto content = TRY(file->read_until_eof());
|
||||
StringView content_view(content);
|
||||
|
||||
::Cpp::Preprocessor processor(path, content_view);
|
||||
|
|
|
@ -20,7 +20,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto content = TRY(file->read_all());
|
||||
auto content = TRY(file->read_until_eof());
|
||||
DeprecatedString name = LexicalPath::basename(path);
|
||||
Cpp::Preprocessor cpp(name, StringView { content });
|
||||
auto tokens = cpp.process_and_lex();
|
||||
|
|
|
@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
outln("Filesystem Blocks Used Available Mount point");
|
||||
}
|
||||
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json_result = TRY(JsonValue::from_string(file_contents));
|
||||
auto const& json = json_result.as_array();
|
||||
json.for_each([](auto& value) {
|
||||
|
|
|
@ -28,7 +28,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
bool color_output = TRY(Core::System::isatty(STDOUT_FILENO));
|
||||
|
||||
auto hunks = Diff::from_text(TRY(file1->read_all()), TRY(file2->read_all()));
|
||||
auto hunks = Diff::from_text(TRY(file1->read_until_eof()), TRY(file2->read_until_eof()));
|
||||
for (auto const& hunk : hunks) {
|
||||
auto original_start = hunk.original_start_line;
|
||||
auto target_start = hunk.target_start_line;
|
||||
|
|
|
@ -15,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/dmesg"sv, Core::Stream::OpenMode::Read));
|
||||
auto buffer = TRY(file->read_all());
|
||||
auto buffer = TRY(file->read_until_eof());
|
||||
out("{}", StringView { buffer });
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& fi
|
|||
du_option.excluded_patterns.append(pattern);
|
||||
if (!exclude_from.is_empty()) {
|
||||
auto file = TRY(Core::Stream::File::open(exclude_from, Core::Stream::OpenMode::Read));
|
||||
auto const buff = TRY(file->read_all());
|
||||
auto const buff = TRY(file->read_until_eof());
|
||||
if (!buff.is_empty()) {
|
||||
DeprecatedString patterns = DeprecatedString::copy(buff, Chomp);
|
||||
du_option.excluded_patterns.extend(patterns.split('\n'));
|
||||
|
|
|
@ -87,7 +87,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Core::System::unveil("/etc/timezone", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
if (!json.is_array()) {
|
||||
warnln("{} does not contain an array of quotes", path);
|
||||
|
|
|
@ -16,7 +16,7 @@ static ErrorOr<bool> format_file(StringView path, bool inplace)
|
|||
auto open_mode = (inplace && !read_from_stdin) ? Core::Stream::OpenMode::ReadWrite : Core::Stream::OpenMode::Read;
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, open_mode));
|
||||
|
||||
auto contents = TRY(file->read_all());
|
||||
auto contents = TRY(file->read_until_eof());
|
||||
auto formatted_gml_or_error = GUI::GML::format_gml(contents);
|
||||
if (formatted_gml_or_error.is_error()) {
|
||||
warnln("Failed to parse GML: {}", formatted_gml_or_error.error());
|
||||
|
|
|
@ -45,7 +45,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
if (use_color) {
|
||||
|
|
|
@ -32,7 +32,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (value_ipv4.is_empty() && value_adapter.is_empty() && value_mask.is_empty()) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
json.as_array().for_each([](auto& value) {
|
||||
|
|
|
@ -370,7 +370,7 @@ static JS::ThrowCompletionOr<JS::Value> load_json_impl(JS::VM& vm)
|
|||
if (file_or_error.is_error())
|
||||
return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error()));
|
||||
|
||||
auto file_contents_or_error = file_or_error.value()->read_all();
|
||||
auto file_contents_or_error = file_or_error.value()->read_until_eof();
|
||||
if (file_contents_or_error.is_error())
|
||||
return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to read '{}': {}", filename, file_contents_or_error.error()));
|
||||
|
||||
|
@ -878,7 +878,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
for (auto& path : script_paths) {
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto source = StringView { file_contents };
|
||||
|
||||
if (Utf8View { file_contents }.validate()) {
|
||||
|
|
|
@ -47,7 +47,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
if (!dotted_key.is_empty()) {
|
||||
auto key_parts = dotted_key.split_view('.');
|
||||
|
|
|
@ -56,21 +56,21 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto maybe_command_set = command_set_file.value()->read_all();
|
||||
auto maybe_command_set = command_set_file.value()->read_until_eof();
|
||||
if (maybe_command_set.is_error()) {
|
||||
dbgln("Error: Could not read {}: {}", command_set_filename, maybe_command_set.error());
|
||||
continue;
|
||||
}
|
||||
DeprecatedString command_set = StringView(maybe_command_set.value().bytes());
|
||||
|
||||
auto maybe_last_lba = last_lba_file.value()->read_all();
|
||||
auto maybe_last_lba = last_lba_file.value()->read_until_eof();
|
||||
if (maybe_last_lba.is_error()) {
|
||||
dbgln("Error: Could not read {}: {}", last_lba_filename, maybe_last_lba.error());
|
||||
continue;
|
||||
}
|
||||
DeprecatedString last_lba = StringView(maybe_last_lba.value().bytes());
|
||||
|
||||
auto maybe_sector_size = sector_size_file.value()->read_all();
|
||||
auto maybe_sector_size = sector_size_file.value()->read_until_eof();
|
||||
if (maybe_sector_size.is_error()) {
|
||||
dbgln("Error: Could not read {}: {}", sector_size_filename, maybe_sector_size.error());
|
||||
continue;
|
||||
|
|
|
@ -60,7 +60,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/cpuinfo"sv, Core::Stream::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
auto const& array = json.as_array();
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
auto file_contents = TRY(proc_interrupts->read_all());
|
||||
auto file_contents = TRY(proc_interrupts->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
auto cpu_count = json.as_array().at(0).as_object().get("per_cpu_call_counts"sv).as_array().size();
|
||||
|
|
|
@ -21,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
outln("Index Name");
|
||||
auto file_contents = TRY(jails_data->read_all());
|
||||
auto file_contents = TRY(jails_data->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
json.as_array().for_each([](auto& value) {
|
||||
auto& jail = value.as_object();
|
||||
|
|
|
@ -70,7 +70,7 @@ static Vector<OpenFile> get_open_files_by_pid(pid_t pid)
|
|||
outln("lsof: PID {}: {}", pid, file.error());
|
||||
return Vector<OpenFile>();
|
||||
}
|
||||
auto data = file.value()->read_all();
|
||||
auto data = file.value()->read_until_eof();
|
||||
if (data.is_error()) {
|
||||
outln("lsof: PID {}: {}", pid, data.error());
|
||||
return {};
|
||||
|
|
|
@ -119,35 +119,35 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto vendor_id_contents = vendor_id_file.value()->read_all();
|
||||
auto vendor_id_contents = vendor_id_file.value()->read_until_eof();
|
||||
if (vendor_id_contents.is_error()) {
|
||||
dbgln("Error: Could not read {}: {}", vendor_id_filename, vendor_id_contents.error());
|
||||
continue;
|
||||
}
|
||||
u32 vendor_id = read_hex_string_from_bytebuffer(vendor_id_contents.value());
|
||||
|
||||
auto device_id_contents = device_id_file.value()->read_all();
|
||||
auto device_id_contents = device_id_file.value()->read_until_eof();
|
||||
if (device_id_contents.is_error()) {
|
||||
dbgln("Error: Could not read {}: {}", device_id_filename, device_id_contents.error());
|
||||
continue;
|
||||
}
|
||||
u32 device_id = read_hex_string_from_bytebuffer(device_id_contents.value());
|
||||
|
||||
auto revision_id_contents = revision_id_file.value()->read_all();
|
||||
auto revision_id_contents = revision_id_file.value()->read_until_eof();
|
||||
if (revision_id_contents.is_error()) {
|
||||
dbgln("Error: Could not read {}: {}", revision_id_filename, revision_id_contents.error());
|
||||
continue;
|
||||
}
|
||||
u32 revision_id = read_hex_string_from_bytebuffer(revision_id_contents.value());
|
||||
|
||||
auto class_id_contents = class_id_file.value()->read_all();
|
||||
auto class_id_contents = class_id_file.value()->read_until_eof();
|
||||
if (class_id_contents.is_error()) {
|
||||
dbgln("Error: Could not read {}: {}", class_id_filename, class_id_contents.error());
|
||||
continue;
|
||||
}
|
||||
u32 class_id = read_hex_string_from_bytebuffer(class_id_contents.value());
|
||||
|
||||
auto subclass_id_contents = subclass_id_file.value()->read_all();
|
||||
auto subclass_id_contents = subclass_id_file.value()->read_until_eof();
|
||||
if (subclass_id_contents.is_error()) {
|
||||
dbgln("Error: Could not read {}: {}", subclass_id_filename, subclass_id_contents.error());
|
||||
continue;
|
||||
|
@ -183,7 +183,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto bar_value_contents = bar_value_file.value()->read_all();
|
||||
auto bar_value_contents = bar_value_file.value()->read_until_eof();
|
||||
if (bar_value_contents.is_error()) {
|
||||
dbgln("Error: Could not read {}: {}", bar_value_filename, bar_value_contents.error());
|
||||
continue;
|
||||
|
|
|
@ -54,7 +54,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto contents = proc_usb_device.value()->read_all();
|
||||
auto contents = proc_usb_device.value()->read_until_eof();
|
||||
if (contents.is_error()) {
|
||||
warnln("Failed to read {}: {}", full_path.string(), contents.error());
|
||||
continue;
|
||||
|
|
|
@ -90,7 +90,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Core::System::pledge("stdio proc"));
|
||||
|
||||
dbgln("Loading man page from {}", TRY(page->path()));
|
||||
auto buffer = TRY(file->read_all());
|
||||
auto buffer = TRY(file->read_until_eof());
|
||||
auto source = DeprecatedString::copy(buffer);
|
||||
|
||||
auto const title = TRY(String::from_utf8("SerenityOS manual"sv));
|
||||
|
|
|
@ -242,7 +242,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
auto file = file_or_error.release_value();
|
||||
|
||||
auto content_buffer_or_error = file->read_all();
|
||||
auto content_buffer_or_error = file->read_until_eof();
|
||||
if (content_buffer_or_error.is_error()) {
|
||||
warnln("Failed to read {}: {}", path, file_or_error.error());
|
||||
// Since this should never happen anyway, fail early.
|
||||
|
|
|
@ -45,7 +45,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
auto buffer = TRY(file->read_all());
|
||||
auto buffer = TRY(file->read_until_eof());
|
||||
dbgln("Read size {}", buffer.size());
|
||||
|
||||
auto input = DeprecatedString::copy(buffer);
|
||||
|
|
|
@ -150,7 +150,7 @@ static ErrorOr<void> print_mounts()
|
|||
// Output info about currently mounted filesystems.
|
||||
auto df = TRY(Core::Stream::File::open("/sys/kernel/df"sv, Core::Stream::OpenMode::Read));
|
||||
|
||||
auto content = TRY(df->read_all());
|
||||
auto content = TRY(df->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(content));
|
||||
|
||||
json.as_array().for_each([](auto& value) {
|
||||
|
|
|
@ -153,7 +153,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (!has_protocol_flag || flag_tcp) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/tcp"sv, Core::Stream::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json_or_error = JsonValue::from_string(file_contents);
|
||||
if (json_or_error.is_error()) {
|
||||
warnln("Error: {}", json_or_error.error());
|
||||
|
@ -245,7 +245,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (!has_protocol_flag || flag_udp) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/udp"sv, Core::Stream::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
Vector<JsonValue> sorted_regions = json.as_array().values();
|
||||
|
|
|
@ -17,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
if (file_or_error.is_error()) {
|
||||
outln("This account is currently not available.");
|
||||
} else {
|
||||
auto message_from_file = TRY(file_or_error.value()->read_all());
|
||||
auto message_from_file = TRY(file_or_error.value()->read_until_eof());
|
||||
out("{}", StringView { message_from_file });
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::pledge("stdio rpath"));
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/cpuinfo"sv, Core::Stream::OpenMode::Read));
|
||||
|
||||
auto buffer = TRY(file->read_all());
|
||||
auto buffer = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(buffer));
|
||||
auto const& cpuinfo_array = json.as_array();
|
||||
outln("{}", cpuinfo_array.size());
|
||||
|
|
|
@ -42,7 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
outln("Address{} Size Access Name", padding);
|
||||
}
|
||||
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
Vector<JsonValue> sorted_regions = json.as_array().values();
|
||||
|
|
|
@ -90,7 +90,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (modify_action.is_empty()) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/route"sv, Core::Stream::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
outln("Kernel IP routing table");
|
||||
|
|
|
@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
ByteBuffer buffer = TRY(file->read_all());
|
||||
ByteBuffer buffer = TRY(file->read_until_eof());
|
||||
|
||||
u8 input_delimiter = is_zero_terminated ? '\0' : '\n';
|
||||
Vector<Bytes> lines;
|
||||
|
|
|
@ -20,7 +20,7 @@ static DeprecatedString get_variable(StringView name)
|
|||
warnln("Failed to open {}: {}", path, file.error());
|
||||
return {};
|
||||
}
|
||||
auto buffer = file.value()->read_all();
|
||||
auto buffer = file.value()->read_until_eof();
|
||||
if (buffer.is_error()) {
|
||||
warnln("Failed to read {}: {}", path, buffer.error());
|
||||
return {};
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
static ErrorOr<void> tail_from_pos(Core::Stream::File& file, off_t startline)
|
||||
{
|
||||
TRY(file.seek(startline + 1, Core::Stream::SeekMode::SetPosition));
|
||||
auto buffer = TRY(file.read_all());
|
||||
auto buffer = TRY(file.read_until_eof());
|
||||
out("{}", StringView { buffer });
|
||||
return {};
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
do {
|
||||
// FIXME: If f is the standard input, f->read_all() does not block
|
||||
// anymore after sending EOF (^D), despite f->is_open() returning true.
|
||||
auto buffer = TRY(f->read_all(PAGE_SIZE));
|
||||
auto buffer = TRY(f->read_until_eof(PAGE_SIZE));
|
||||
auto line_count = StringView(buffer).count("\n"sv);
|
||||
auto bytes = buffer.bytes();
|
||||
size_t line_index = 0;
|
||||
|
@ -108,7 +108,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto watcher = TRY(Core::FileWatcher::create());
|
||||
watcher->on_change = [&](Core::FileWatcherEvent const& event) {
|
||||
if (event.type == Core::FileWatcherEvent::Type::ContentModified) {
|
||||
auto buffer_or_error = f->read_all();
|
||||
auto buffer_or_error = f->read_until_eof();
|
||||
if (buffer_or_error.is_error()) {
|
||||
auto error = buffer_or_error.error();
|
||||
warnln(error.string_literal());
|
||||
|
|
|
@ -152,7 +152,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto fn = parse_target_name(type);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
|
||||
auto input = TRY(file->read_all());
|
||||
auto input = TRY(file->read_until_eof());
|
||||
|
||||
return fn(input.data(), input.size());
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto file = TRY(Core::Stream::File::open("/var/run/utmp"sv, Core::Stream::OpenMode::ReadWrite));
|
||||
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto previous_json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
JsonObject json;
|
||||
|
|
|
@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto file = TRY(Core::Stream::File::open("/var/run/utmp"sv, Core::Stream::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_all());
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
if (!json.is_object()) {
|
||||
warnln("Error: Could not parse /var/run/utmp");
|
||||
|
|
|
@ -372,7 +372,7 @@ static auto parse(StringView contents)
|
|||
return Error::from_string_literal("NYI: Nonlocal entity");
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read));
|
||||
return DeprecatedString::copy(TRY(file->read_all()));
|
||||
return DeprecatedString::copy(TRY(file->read_until_eof()));
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -449,7 +449,7 @@ static void do_run_tests(XML::Document& document)
|
|||
|
||||
warnln("Running test {}", url.path());
|
||||
|
||||
auto contents = file_result.value()->read_all();
|
||||
auto contents = file_result.value()->read_until_eof();
|
||||
if (contents.is_error()) {
|
||||
warnln("Read error for {}: {}", url.path(), contents.error());
|
||||
s_test_results.set(url.path(), TestResult::RunnerFailed);
|
||||
|
@ -474,7 +474,7 @@ static void do_run_tests(XML::Document& document)
|
|||
s_test_results.set(url.path(), TestResult::RunnerFailed);
|
||||
continue;
|
||||
}
|
||||
auto contents = file_result.value()->read_all();
|
||||
auto contents = file_result.value()->read_until_eof();
|
||||
if (contents.is_error()) {
|
||||
warnln("Read error for {}: {}", out_path, contents.error());
|
||||
s_test_results.set(url.path(), TestResult::RunnerFailed);
|
||||
|
@ -517,7 +517,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
s_path = Core::File::real_path_for(filename);
|
||||
auto file = TRY(Core::Stream::File::open(s_path, Core::Stream::OpenMode::Read));
|
||||
auto contents = TRY(file->read_all());
|
||||
auto contents = TRY(file->read_until_eof());
|
||||
|
||||
auto xml_parser = parse(contents);
|
||||
auto result = xml_parser.parse();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue