diff options
Diffstat (limited to 'Userland')
56 files changed, 77 insertions, 77 deletions
diff --git a/Userland/Applets/Network/main.cpp b/Userland/Applets/Network/main.cpp index 758644bd96..7a3f3bac75 100644 --- a/Userland/Applets/Network/main.cpp +++ b/Userland/Applets/Network/main.cpp @@ -113,7 +113,7 @@ private: return ""; } - 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()) { dbgln("Error: Could not read /sys/kernel/net/adapters: {}", file_contents_or_error.error()); return ""; diff --git a/Userland/Applets/ResourceGraph/main.cpp b/Userland/Applets/ResourceGraph/main.cpp index 392e2140a5..442ac13be6 100644 --- a/Userland/Applets/ResourceGraph/main.cpp +++ b/Userland/Applets/ResourceGraph/main.cpp @@ -153,7 +153,7 @@ private: file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read)); } - auto file_contents = TRY(file->read_all()); + auto file_contents = TRY(file->read_until_eof()); return TRY(JsonValue::from_string(file_contents)); } diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp index 851c8ad91f..d9809de9ae 100644 --- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp +++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp @@ -64,7 +64,7 @@ NetworkSettingsWidget::NetworkSettingsWidget() auto config_file = Core::ConfigFile::open_for_system("Network").release_value_but_fixme_should_propagate_errors(); auto proc_net_adapters_file = Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); - auto data = proc_net_adapters_file->read_all().release_value_but_fixme_should_propagate_errors(); + auto data = proc_net_adapters_file->read_until_eof().release_value_but_fixme_should_propagate_errors(); JsonParser parser(data); JsonValue proc_net_adapters_json = parser.parse().release_value_but_fixme_should_propagate_errors(); diff --git a/Userland/Applications/Presenter/Presentation.cpp b/Userland/Applications/Presenter/Presentation.cpp index b58944184b..b1d809f908 100644 --- a/Userland/Applications/Presenter/Presentation.cpp +++ b/Userland/Applications/Presenter/Presentation.cpp @@ -67,7 +67,7 @@ ErrorOr<NonnullOwnPtr<Presentation>> Presentation::load_from_file(StringView fil if (file_name.is_empty()) return ENOENT; auto file = TRY(Core::Stream::File::open_file_or_standard_stream(file_name, Core::Stream::OpenMode::Read)); - auto contents = TRY(file->read_all()); + auto contents = TRY(file->read_until_eof()); auto content_string = StringView { contents }; auto json = TRY(JsonValue::from_string(content_string)); diff --git a/Userland/Applications/Presenter/SlideObject.cpp b/Userland/Applications/Presenter/SlideObject.cpp index 108d5cea9a..931a8e2a1c 100644 --- a/Userland/Applications/Presenter/SlideObject.cpp +++ b/Userland/Applications/Presenter/SlideObject.cpp @@ -113,7 +113,7 @@ Image::Image(NonnullRefPtr<ImageDecoderClient::Client> client, NonnullRefPtr<GUI ErrorOr<void> Image::reload_image() { auto file = TRY(Core::Stream::File::open(m_image_path, Core::Stream::OpenMode::Read)); - auto data = TRY(file->read_all()); + auto data = TRY(file->read_until_eof()); auto maybe_decoded = m_client->decode_image(data); if (!maybe_decoded.has_value() || maybe_decoded.value().frames.size() < 1) return Error::from_string_view("Could not decode image"sv); diff --git a/Userland/Applications/SoundPlayer/M3UParser.cpp b/Userland/Applications/SoundPlayer/M3UParser.cpp index 2ba0b0fead..5cd76a45cc 100644 --- a/Userland/Applications/SoundPlayer/M3UParser.cpp +++ b/Userland/Applications/SoundPlayer/M3UParser.cpp @@ -18,7 +18,7 @@ M3UParser::M3UParser() NonnullOwnPtr<M3UParser> M3UParser::from_file(StringView path) { auto file_result = Core::Stream::File::open(path, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); - auto contents = file_result->read_all().release_value_but_fixme_should_propagate_errors(); + auto contents = file_result->read_until_eof().release_value_but_fixme_should_propagate_errors(); auto use_utf8 = path.ends_with(".m3u8"sv, CaseSensitivity::CaseInsensitive); return from_memory(DeprecatedString { contents, NoChomp }, use_utf8); } diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index e66e2b88f4..cc895304a2 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -86,7 +86,7 @@ static ErrorOr<void> fill_mounts(Vector<MountInfo>& output) // Output info about currently mounted filesystems. auto file = TRY(Core::Stream::File::open("/sys/kernel/df"sv, Core::Stream::OpenMode::Read)); - auto content = TRY(file->read_all()); + auto content = TRY(file->read_until_eof()); auto json = TRY(JsonValue::from_string(content)); TRY(json.as_array().try_for_each([&output](JsonValue const& value) -> ErrorOr<void> { diff --git a/Userland/Applications/SystemMonitor/ProcessModel.cpp b/Userland/Applications/SystemMonitor/ProcessModel.cpp index 119913ea45..baaacd4a64 100644 --- a/Userland/Applications/SystemMonitor/ProcessModel.cpp +++ b/Userland/Applications/SystemMonitor/ProcessModel.cpp @@ -411,7 +411,7 @@ Vector<GUI::ModelIndex> ProcessModel::matches(StringView searching, unsigned fla static ErrorOr<DeprecatedString> try_read_command_line(pid_t pid) { auto file = TRY(Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/cmdline", pid), Core::Stream::OpenMode::Read)); - auto data = TRY(file->read_all()); + auto data = TRY(file->read_until_eof()); auto json = TRY(JsonValue::from_string(StringView { data.bytes() })); auto array = json.as_array().values(); return DeprecatedString::join(" "sv, array); diff --git a/Userland/DevTools/Profiler/Profile.cpp b/Userland/DevTools/Profiler/Profile.cpp index 656f159ae6..d7f4418b9e 100644 --- a/Userland/DevTools/Profiler/Profile.cpp +++ b/Userland/DevTools/Profiler/Profile.cpp @@ -238,7 +238,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path { auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); - auto json = JsonValue::from_string(TRY(file->read_all())); + auto json = JsonValue::from_string(TRY(file->read_until_eof())); if (json.is_error() || !json.value().is_object()) return Error::from_string_literal("Invalid perfcore format (not a JSON object)"); diff --git a/Userland/DevTools/SQLStudio/ScriptEditor.cpp b/Userland/DevTools/SQLStudio/ScriptEditor.cpp index 4cf7cd3fa6..539e979e9c 100644 --- a/Userland/DevTools/SQLStudio/ScriptEditor.cpp +++ b/Userland/DevTools/SQLStudio/ScriptEditor.cpp @@ -29,7 +29,7 @@ void ScriptEditor::new_script_with_temp_name(DeprecatedString name) ErrorOr<void> ScriptEditor::open_script_from_file(LexicalPath const& file_path) { auto file = TRY(Core::Stream::File::open(file_path.string(), Core::Stream::OpenMode::Read)); - auto buffer = TRY(file->read_all()); + auto buffer = TRY(file->read_until_eof()); set_text({ buffer.bytes() }); m_path = file_path.string(); diff --git a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp index 8f2ea44cc0..975e16987c 100644 --- a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp +++ b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp @@ -21,7 +21,7 @@ ErrorOr<AllProcessesStatistics> ProcessStatisticsReader::get_all(Core::Stream::S AllProcessesStatistics all_processes_statistics; - auto file_contents = TRY(proc_all_file.read_all()); + auto file_contents = TRY(proc_all_file.read_until_eof()); auto json_obj = TRY(JsonValue::from_string(file_contents)).as_object(); json_obj.get("processes"sv).as_array().for_each([&](auto& value) { const JsonObject& process_object = value.as_object(); diff --git a/Userland/Libraries/LibCore/Stream.cpp b/Userland/Libraries/LibCore/Stream.cpp index aab023c26f..ba69c533c7 100644 --- a/Userland/Libraries/LibCore/Stream.cpp +++ b/Userland/Libraries/LibCore/Stream.cpp @@ -47,12 +47,12 @@ bool Stream::read_or_error(Bytes buffer) return true; } -ErrorOr<ByteBuffer> Stream::read_all(size_t block_size) +ErrorOr<ByteBuffer> Stream::read_until_eof(size_t block_size) { - return read_all_impl(block_size); + return read_until_eof_impl(block_size); } -ErrorOr<ByteBuffer> Stream::read_all_impl(size_t block_size, size_t expected_file_size) +ErrorOr<ByteBuffer> Stream::read_until_eof_impl(size_t block_size, size_t expected_file_size) { ByteBuffer data; data.ensure_capacity(expected_file_size); @@ -243,12 +243,12 @@ ErrorOr<Bytes> File::read(Bytes buffer) return buffer.trim(nread); } -ErrorOr<ByteBuffer> File::read_all(size_t block_size) +ErrorOr<ByteBuffer> File::read_until_eof(size_t block_size) { // Note: This is used as a heuristic, it's not valid for devices or virtual files. auto const potential_file_size = TRY(System::fstat(m_fd)).st_size; - return read_all_impl(block_size, potential_file_size); + return read_until_eof_impl(block_size, potential_file_size); } ErrorOr<size_t> File::write(ReadonlyBytes buffer) diff --git a/Userland/Libraries/LibCore/Stream.h b/Userland/Libraries/LibCore/Stream.h index f57bcc0400..550a376e03 100644 --- a/Userland/Libraries/LibCore/Stream.h +++ b/Userland/Libraries/LibCore/Stream.h @@ -39,7 +39,7 @@ public: /// Reads the stream until EOF, storing the contents into a ByteBuffer which /// is returned once EOF is encountered. The block size determines the size /// of newly allocated chunks while reading. - virtual ErrorOr<ByteBuffer> read_all(size_t block_size = 4096); + virtual ErrorOr<ByteBuffer> read_until_eof(size_t block_size = 4096); /// Discards the given number of bytes from the stream. /// Unless specifically overwritten, this just uses read() to read into an /// internal stack-based buffer. @@ -69,12 +69,12 @@ public: } protected: - /// Provides a default implementation of read_all that works for streams + /// Provides a default implementation of read_until_eof that works for streams /// that behave like POSIX file descriptors. expected_file_size can be /// passed as a heuristic for what the Stream subclass expects the file /// content size to be in order to reduce allocations (does not affect /// actual reading). - ErrorOr<ByteBuffer> read_all_impl(size_t block_size, size_t expected_file_size = 0); + ErrorOr<ByteBuffer> read_until_eof_impl(size_t block_size, size_t expected_file_size = 0); }; enum class SeekMode { @@ -238,7 +238,7 @@ public: } virtual ErrorOr<Bytes> read(Bytes) override; - virtual ErrorOr<ByteBuffer> read_all(size_t block_size = 4096) override; + virtual ErrorOr<ByteBuffer> read_until_eof(size_t block_size = 4096) override; virtual ErrorOr<size_t> write(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override; diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp index 8e08879d83..5ab3ea0458 100644 --- a/Userland/Libraries/LibHTTP/Job.cpp +++ b/Userland/Libraries/LibHTTP/Job.cpp @@ -86,7 +86,7 @@ static Optional<ByteBuffer> handle_content_encoding(ByteBuffer const& buf, Depre auto bufstream = bufstream_result.release_value(); auto brotli_stream = Compress::BrotliDecompressionStream { *bufstream }; - auto uncompressed = brotli_stream.read_all(); + auto uncompressed = brotli_stream.read_until_eof(); if (uncompressed.is_error()) { dbgln("Job::handle_content_encoding: Brotli::decompress() failed: {}.", uncompressed.error()); return {}; diff --git a/Userland/Libraries/LibSQL/SQLClient.cpp b/Userland/Libraries/LibSQL/SQLClient.cpp index e98f2483bb..df72ca1eb9 100644 --- a/Userland/Libraries/LibSQL/SQLClient.cpp +++ b/Userland/Libraries/LibSQL/SQLClient.cpp @@ -104,7 +104,7 @@ static ErrorOr<bool> should_launch_server(DeprecatedString const& pid_path) return server_pid_file.release_error(); } - auto contents = server_pid_file.value()->read_all(); + auto contents = server_pid_file.value()->read_until_eof(); if (contents.is_error()) { warnln("Could not read SQLServer PID file '{}': {}", pid_path, contents.error()); return contents.release_error(); diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index ef061baa0b..475b3930bb 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -243,7 +243,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has } auto file = maybe_file.release_value(); - auto maybe_data = file->read_all(); + auto maybe_data = file->read_until_eof(); if (maybe_data.is_error()) { log_failure(request, maybe_data.error()); if (error_callback) diff --git a/Userland/Services/NetworkServer/main.cpp b/Userland/Services/NetworkServer/main.cpp index 2c50879ea7..45936d97d7 100644 --- a/Userland/Services/NetworkServer/main.cpp +++ b/Userland/Services/NetworkServer/main.cpp @@ -29,7 +29,7 @@ ErrorOr<int> serenity_main(Main::Arguments) auto config_file = TRY(Core::ConfigFile::open_for_system("Network")); auto proc_net_adapters_file = TRY(Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read)); - auto data = TRY(proc_net_adapters_file->read_all()); + auto data = TRY(proc_net_adapters_file->read_until_eof()); JsonParser parser(data); JsonValue proc_net_adapters_json = TRY(parser.parse()); diff --git a/Userland/Utilities/arp.cpp b/Userland/Utilities/arp.cpp index 1f27f4a552..e34d620fec 100644 --- a/Userland/Utilities/arp.cpp +++ b/Userland/Utilities/arp.cpp @@ -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(); diff --git a/Userland/Utilities/base64.cpp b/Userland/Utilities/base64.cpp index dbcd0a1221..e4e2b1dfcd 100644 --- a/Userland/Utilities/base64.cpp +++ b/Userland/Utilities/base64.cpp @@ -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")); diff --git a/Userland/Utilities/copy.cpp b/Userland/Utilities/copy.cpp index 1a6f80de9f..b3103c7146 100644 --- a/Userland/Utilities/copy.cpp +++ b/Userland/Utilities/copy.cpp @@ -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(); diff --git a/Userland/Utilities/cpp-lexer.cpp b/Userland/Utilities/cpp-lexer.cpp index 1bce9e6f7f..fdbe49c5e8 100644 --- a/Userland/Utilities/cpp-lexer.cpp +++ b/Userland/Utilities/cpp-lexer.cpp @@ -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); diff --git a/Userland/Utilities/cpp-parser.cpp b/Userland/Utilities/cpp-parser.cpp index 790dc42868..91e6f5a4de 100644 --- a/Userland/Utilities/cpp-parser.cpp +++ b/Userland/Utilities/cpp-parser.cpp @@ -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); diff --git a/Userland/Utilities/cpp-preprocessor.cpp b/Userland/Utilities/cpp-preprocessor.cpp index e3c97fa848..34e6148471 100644 --- a/Userland/Utilities/cpp-preprocessor.cpp +++ b/Userland/Utilities/cpp-preprocessor.cpp @@ -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(); diff --git a/Userland/Utilities/df.cpp b/Userland/Utilities/df.cpp index d53e90bed3..e3ba52013e 100644 --- a/Userland/Utilities/df.cpp +++ b/Userland/Utilities/df.cpp @@ -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) { diff --git a/Userland/Utilities/diff.cpp b/Userland/Utilities/diff.cpp index b4df9da59a..b15a2f9bb4 100644 --- a/Userland/Utilities/diff.cpp +++ b/Userland/Utilities/diff.cpp @@ -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; diff --git a/Userland/Utilities/dmesg.cpp b/Userland/Utilities/dmesg.cpp index 05181b3246..cb5e94baf4 100644 --- a/Userland/Utilities/dmesg.cpp +++ b/Userland/Utilities/dmesg.cpp @@ -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; } diff --git a/Userland/Utilities/du.cpp b/Userland/Utilities/du.cpp index 938dd5d9be..d018e79d5a 100644 --- a/Userland/Utilities/du.cpp +++ b/Userland/Utilities/du.cpp @@ -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')); diff --git a/Userland/Utilities/fortune.cpp b/Userland/Utilities/fortune.cpp index 87b2d19bf8..3c76ae30db 100644 --- a/Userland/Utilities/fortune.cpp +++ b/Userland/Utilities/fortune.cpp @@ -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); diff --git a/Userland/Utilities/gml-format.cpp b/Userland/Utilities/gml-format.cpp index a57c62b3df..37d10475fe 100644 --- a/Userland/Utilities/gml-format.cpp +++ b/Userland/Utilities/gml-format.cpp @@ -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()); diff --git a/Userland/Utilities/gron.cpp b/Userland/Utilities/gron.cpp index d96c44c3cc..6e77a33f03 100644 --- a/Userland/Utilities/gron.cpp +++ b/Userland/Utilities/gron.cpp @@ -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) { diff --git a/Userland/Utilities/ifconfig.cpp b/Userland/Utilities/ifconfig.cpp index b532594f0c..2489e57ce7 100644 --- a/Userland/Utilities/ifconfig.cpp +++ b/Userland/Utilities/ifconfig.cpp @@ -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) { diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index fb0965debf..7e1a105341 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -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()) { diff --git a/Userland/Utilities/json.cpp b/Userland/Utilities/json.cpp index d88542af51..33907ed061 100644 --- a/Userland/Utilities/json.cpp +++ b/Userland/Utilities/json.cpp @@ -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('.'); diff --git a/Userland/Utilities/lsblk.cpp b/Userland/Utilities/lsblk.cpp index b519a02dcc..e6d611ff45 100644 --- a/Userland/Utilities/lsblk.cpp +++ b/Userland/Utilities/lsblk.cpp @@ -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; diff --git a/Userland/Utilities/lscpu.cpp b/Userland/Utilities/lscpu.cpp index 0cfac0606c..6a227298b6 100644 --- a/Userland/Utilities/lscpu.cpp +++ b/Userland/Utilities/lscpu.cpp @@ -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(); diff --git a/Userland/Utilities/lsirq.cpp b/Userland/Utilities/lsirq.cpp index 37f41868c7..c4542013df 100644 --- a/Userland/Utilities/lsirq.cpp +++ b/Userland/Utilities/lsirq.cpp @@ -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(); diff --git a/Userland/Utilities/lsjails.cpp b/Userland/Utilities/lsjails.cpp index 4ec5e234f0..ccf3438783 100644 --- a/Userland/Utilities/lsjails.cpp +++ b/Userland/Utilities/lsjails.cpp @@ -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(); diff --git a/Userland/Utilities/lsof.cpp b/Userland/Utilities/lsof.cpp index 5d38b6e24d..eef27eee81 100644 --- a/Userland/Utilities/lsof.cpp +++ b/Userland/Utilities/lsof.cpp @@ -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 {}; diff --git a/Userland/Utilities/lspci.cpp b/Userland/Utilities/lspci.cpp index 715fc72a6f..feac6a4ae6 100644 --- a/Userland/Utilities/lspci.cpp +++ b/Userland/Utilities/lspci.cpp @@ -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; diff --git a/Userland/Utilities/lsusb.cpp b/Userland/Utilities/lsusb.cpp index 473e33e845..f721a86420 100644 --- a/Userland/Utilities/lsusb.cpp +++ b/Userland/Utilities/lsusb.cpp @@ -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; diff --git a/Userland/Utilities/man.cpp b/Userland/Utilities/man.cpp index 7d0117496a..4ab40b9694 100644 --- a/Userland/Utilities/man.cpp +++ b/Userland/Utilities/man.cpp @@ -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)); diff --git a/Userland/Utilities/markdown-check.cpp b/Userland/Utilities/markdown-check.cpp index c4d438927c..e8eba49863 100644 --- a/Userland/Utilities/markdown-check.cpp +++ b/Userland/Utilities/markdown-check.cpp @@ -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. diff --git a/Userland/Utilities/md.cpp b/Userland/Utilities/md.cpp index 266175eb3e..a027043219 100644 --- a/Userland/Utilities/md.cpp +++ b/Userland/Utilities/md.cpp @@ -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); diff --git a/Userland/Utilities/mount.cpp b/Userland/Utilities/mount.cpp index bee21b39a0..21e731f58b 100644 --- a/Userland/Utilities/mount.cpp +++ b/Userland/Utilities/mount.cpp @@ -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) { diff --git a/Userland/Utilities/netstat.cpp b/Userland/Utilities/netstat.cpp index 50cdf124cc..c39a800acf 100644 --- a/Userland/Utilities/netstat.cpp +++ b/Userland/Utilities/netstat.cpp @@ -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(); diff --git a/Userland/Utilities/nologin.cpp b/Userland/Utilities/nologin.cpp index 0808b4ce37..8c187d9764 100644 --- a/Userland/Utilities/nologin.cpp +++ b/Userland/Utilities/nologin.cpp @@ -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 }); } diff --git a/Userland/Utilities/nproc.cpp b/Userland/Utilities/nproc.cpp index f49bf86687..54f730fe7a 100644 --- a/Userland/Utilities/nproc.cpp +++ b/Userland/Utilities/nproc.cpp @@ -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()); diff --git a/Userland/Utilities/pmap.cpp b/Userland/Utilities/pmap.cpp index b38fcbbc20..c6060d5640 100644 --- a/Userland/Utilities/pmap.cpp +++ b/Userland/Utilities/pmap.cpp @@ -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(); diff --git a/Userland/Utilities/route.cpp b/Userland/Utilities/route.cpp index 633bb58595..420ba50918 100644 --- a/Userland/Utilities/route.cpp +++ b/Userland/Utilities/route.cpp @@ -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"); diff --git a/Userland/Utilities/shuf.cpp b/Userland/Utilities/shuf.cpp index f291daab42..0583969e6b 100644 --- a/Userland/Utilities/shuf.cpp +++ b/Userland/Utilities/shuf.cpp @@ -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; diff --git a/Userland/Utilities/sysctl.cpp b/Userland/Utilities/sysctl.cpp index 25bda336c6..c234edbf85 100644 --- a/Userland/Utilities/sysctl.cpp +++ b/Userland/Utilities/sysctl.cpp @@ -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 {}; diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp index b5e8597fe4..2f71f45318 100644 --- a/Userland/Utilities/tail.cpp +++ b/Userland/Utilities/tail.cpp @@ -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()); diff --git a/Userland/Utilities/test-fuzz.cpp b/Userland/Utilities/test-fuzz.cpp index 2a0b0c7bba..fea99e8686 100644 --- a/Userland/Utilities/test-fuzz.cpp +++ b/Userland/Utilities/test-fuzz.cpp @@ -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()); } diff --git a/Userland/Utilities/utmpupdate.cpp b/Userland/Utilities/utmpupdate.cpp index 7c011243f1..b7eec59b13 100644 --- a/Userland/Utilities/utmpupdate.cpp +++ b/Userland/Utilities/utmpupdate.cpp @@ -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; diff --git a/Userland/Utilities/w.cpp b/Userland/Utilities/w.cpp index 5e3f0a7dc9..ca82674bc5 100644 --- a/Userland/Utilities/w.cpp +++ b/Userland/Utilities/w.cpp @@ -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"); diff --git a/Userland/Utilities/xml.cpp b/Userland/Utilities/xml.cpp index fc91876e3f..6ccd0b9f6d 100644 --- a/Userland/Utilities/xml.cpp +++ b/Userland/Utilities/xml.cpp @@ -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(); |