diff options
Diffstat (limited to 'Userland/Utilities')
65 files changed, 170 insertions, 111 deletions
diff --git a/Userland/Utilities/arp.cpp b/Userland/Utilities/arp.cpp index 066474b46b..89324c8f7a 100644 --- a/Userland/Utilities/arp.cpp +++ b/Userland/Utilities/arp.cpp @@ -12,6 +12,7 @@ #include <AK/QuickSort.h> #include <AK/Types.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -92,7 +93,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) outln(); if (!flag_set && !flag_delete) { - auto file = TRY(Core::Stream::File::open("/sys/kernel/net/arp"sv, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open("/sys/kernel/net/arp"sv, Core::File::OpenMode::Read)); auto file_contents = TRY(file->read_until_eof()); auto json = TRY(JsonValue::from_string(file_contents)); diff --git a/Userland/Utilities/base64.cpp b/Userland/Utilities/base64.cpp index a622ea8ca6..9aa05d3197 100644 --- a/Userland/Utilities/base64.cpp +++ b/Userland/Utilities/base64.cpp @@ -6,6 +6,7 @@ #include <AK/Base64.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -22,7 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(filepath, "", "file", Core::ArgsParser::Required::No); args_parser.parse(arguments); - auto file = TRY(Core::Stream::File::open_file_or_standard_stream(filepath, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open_file_or_standard_stream(filepath, Core::File::OpenMode::Read)); ByteBuffer buffer = TRY(file->read_until_eof()); TRY(Core::System::pledge("stdio")); diff --git a/Userland/Utilities/cat.cpp b/Userland/Utilities/cat.cpp index 000b26d739..ea5e558f0e 100644 --- a/Userland/Utilities/cat.cpp +++ b/Userland/Utilities/cat.cpp @@ -7,6 +7,7 @@ #include <AK/Vector.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -25,11 +26,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (paths.is_empty()) paths.append("-"sv); - Vector<NonnullOwnPtr<Core::Stream::File>> files; + Vector<NonnullOwnPtr<Core::File>> files; TRY(files.try_ensure_capacity(paths.size())); for (auto const& path : paths) { - if (auto result = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read); result.is_error()) + if (auto result = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read); result.is_error()) warnln("Failed to open {}: {}", path, result.release_error()); else files.unchecked_append(result.release_value()); diff --git a/Userland/Utilities/checksum.cpp b/Userland/Utilities/checksum.cpp index 5ac56e8cb4..abb566ab04 100644 --- a/Userland/Utilities/checksum.cpp +++ b/Userland/Utilities/checksum.cpp @@ -6,6 +6,7 @@ #include <AK/LexicalPath.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibCrypto/Hash/HashManager.h> @@ -55,7 +56,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) int failed_verification_count = 0; for (auto const& path : paths) { - auto file_or_error = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read); + auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read); if (file_or_error.is_error()) { ++read_fail_count; has_error = true; @@ -87,7 +88,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) // line[0] = checksum // line[1] = filename StringView const filename = line[1]; - auto file_from_filename_or_error = Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read); + auto file_from_filename_or_error = Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read); if (file_from_filename_or_error.is_error()) { ++read_fail_count; warnln("{}: {}", filename, file_from_filename_or_error.release_error()); diff --git a/Userland/Utilities/cksum.cpp b/Userland/Utilities/cksum.cpp index 08c7cb0be3..ba1b102801 100644 --- a/Userland/Utilities/cksum.cpp +++ b/Userland/Utilities/cksum.cpp @@ -5,6 +5,7 @@ */ #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibCrypto/Checksum/Adler32.h> @@ -46,7 +47,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) Array<u8, PAGE_SIZE> buffer; for (auto& path : paths) { - auto file_or_error = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read); + auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read); auto filepath = (path == "-") ? "/dev/stdin" : path; if (file_or_error.is_error()) { warnln("{}: {}: {}", arguments.strings[0], filepath, file_or_error.error()); diff --git a/Userland/Utilities/cmp.cpp b/Userland/Utilities/cmp.cpp index 8837098992..ac213cb88b 100644 --- a/Userland/Utilities/cmp.cpp +++ b/Userland/Utilities/cmp.cpp @@ -5,20 +5,21 @@ */ #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> #include <unistd.h> -static ErrorOr<NonnullOwnPtr<Core::Stream::BufferedFile>> open_file_or_stdin(DeprecatedString const& filename) +static ErrorOr<NonnullOwnPtr<Core::BufferedFile>> open_file_or_stdin(DeprecatedString const& filename) { - OwnPtr<Core::Stream::File> file; + OwnPtr<Core::File> file; if (filename == "-") { - file = TRY(Core::Stream::File::adopt_fd(STDIN_FILENO, Core::Stream::OpenMode::Read)); + file = TRY(Core::File::adopt_fd(STDIN_FILENO, Core::File::OpenMode::Read)); } else { - file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read)); + file = TRY(Core::File::open(filename, Core::File::OpenMode::Read)); } - return TRY(Core::Stream::BufferedFile::create(file.release_nonnull())); + return TRY(Core::BufferedFile::create(file.release_nonnull())); } ErrorOr<int> serenity_main(Main::Arguments arguments) diff --git a/Userland/Utilities/comm.cpp b/Userland/Utilities/comm.cpp index 370bdc4ea1..0040c94ce4 100644 --- a/Userland/Utilities/comm.cpp +++ b/Userland/Utilities/comm.cpp @@ -7,6 +7,7 @@ #include <LibCore/ArgsParser.h> #include <LibCore/DeprecatedFile.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -62,7 +63,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } auto open_file = [](DeprecatedString const& path, auto& file, int file_number) { - auto file_or_error = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read); + auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read); if (file_or_error.is_error()) { warnln("Failed to open file{} '{}': {}", file_number, path, file_or_error.error()); return false; @@ -73,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return false; } - auto buffered_file_or_error = Core::Stream::BufferedFile::create(file_or_error.release_value()); + auto buffered_file_or_error = Core::BufferedFile::create(file_or_error.release_value()); if (buffered_file_or_error.is_error()) { warnln("Failed to create buffer for file{} '{}': {}", file_number, path, buffered_file_or_error.error()); return false; @@ -83,8 +84,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return true; }; - OwnPtr<Core::Stream::BufferedFile> file1; - OwnPtr<Core::Stream::BufferedFile> file2; + OwnPtr<Core::BufferedFile> file1; + OwnPtr<Core::BufferedFile> file2; if (!(open_file(file1_path, file1, 1) && open_file(file2_path, file2, 2))) return 1; diff --git a/Userland/Utilities/copy.cpp b/Userland/Utilities/copy.cpp index b3103c7146..c9122d46f3 100644 --- a/Userland/Utilities/copy.cpp +++ b/Userland/Utilities/copy.cpp @@ -9,6 +9,7 @@ #include <AK/DeprecatedString.h> #include <AK/StringBuilder.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibGUI/Application.h> #include <LibGUI/Clipboard.h> @@ -42,7 +43,7 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments) // We're not copying anything. } else if (text.is_empty()) { // Copy our stdin. - auto c_stdin = TRY(Core::Stream::File::standard_input()); + auto c_stdin = TRY(Core::File::standard_input()); auto buffer = TRY(c_stdin->read_until_eof()); dbgln("Read size {}", buffer.size()); dbgln("Read data: `{}`", StringView(buffer.bytes())); diff --git a/Userland/Utilities/cpp-lexer.cpp b/Userland/Utilities/cpp-lexer.cpp index fdbe49c5e8..aa0fdafe20 100644 --- a/Userland/Utilities/cpp-lexer.cpp +++ b/Userland/Utilities/cpp-lexer.cpp @@ -6,6 +6,7 @@ #include <AK/Try.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCpp/Lexer.h> #include <LibMain/Main.h> @@ -17,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(path, "Cpp File", "cpp-file", Core::ArgsParser::Required::Yes); args_parser.parse(arguments); - auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); auto content = TRY(file->read_until_eof()); StringView content_view(content); diff --git a/Userland/Utilities/cpp-parser.cpp b/Userland/Utilities/cpp-parser.cpp index 91e6f5a4de..683b9ed241 100644 --- a/Userland/Utilities/cpp-parser.cpp +++ b/Userland/Utilities/cpp-parser.cpp @@ -5,6 +5,7 @@ */ #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCpp/Parser.h> #include <LibMain/Main.h> @@ -20,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 file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); auto content = TRY(file->read_until_eof()); StringView content_view(content); diff --git a/Userland/Utilities/cpp-preprocessor.cpp b/Userland/Utilities/cpp-preprocessor.cpp index 34e6148471..4414e53752 100644 --- a/Userland/Utilities/cpp-preprocessor.cpp +++ b/Userland/Utilities/cpp-preprocessor.cpp @@ -6,6 +6,7 @@ #include <AK/LexicalPath.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCpp/Preprocessor.h> #include <LibMain/Main.h> @@ -19,7 +20,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_option(print_definitions, "Print preprocessor definitions", "definitions", 'D'); args_parser.parse(arguments); - auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); auto content = TRY(file->read_until_eof()); DeprecatedString name = LexicalPath::basename(path); Cpp::Preprocessor cpp(name, StringView { content }); diff --git a/Userland/Utilities/df.cpp b/Userland/Utilities/df.cpp index a80945aa81..56bef8ed89 100644 --- a/Userland/Utilities/df.cpp +++ b/Userland/Utilities/df.cpp @@ -8,6 +8,7 @@ #include <AK/JsonObject.h> #include <AK/NumberFormat.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibMain/Main.h> #include <inttypes.h> @@ -36,7 +37,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_option(flag_inode_info, "Show inode information as well", "inodes", 'i'); args_parser.parse(arguments); - auto file = TRY(Core::Stream::File::open("/sys/kernel/df"sv, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open("/sys/kernel/df"sv, Core::File::OpenMode::Read)); Vector<StringView> headers; TRY(headers.try_append(flag_human_readable ? "Size"sv : "Blocks"sv)); diff --git a/Userland/Utilities/diff.cpp b/Userland/Utilities/diff.cpp index 9ec39cabe1..c26318ac40 100644 --- a/Userland/Utilities/diff.cpp +++ b/Userland/Utilities/diff.cpp @@ -5,6 +5,7 @@ */ #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibDiff/Generator.h> @@ -23,8 +24,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) parser.add_positional_argument(filename2, "Second file to compare", "file2", Core::ArgsParser::Required::Yes); parser.parse(arguments); - auto file1 = TRY(Core::Stream::File::open(filename1, Core::Stream::OpenMode::Read)); - auto file2 = TRY(Core::Stream::File::open(filename2, Core::Stream::OpenMode::Read)); + auto file1 = TRY(Core::File::open(filename1, Core::File::OpenMode::Read)); + auto file2 = TRY(Core::File::open(filename2, Core::File::OpenMode::Read)); bool color_output = TRY(Core::System::isatty(STDOUT_FILENO)); diff --git a/Userland/Utilities/dmesg.cpp b/Userland/Utilities/dmesg.cpp index cb5e94baf4..459b06e425 100644 --- a/Userland/Utilities/dmesg.cpp +++ b/Userland/Utilities/dmesg.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -14,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments) TRY(Core::System::unveil("/sys/kernel/dmesg", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto file = TRY(Core::Stream::File::open("/sys/kernel/dmesg"sv, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open("/sys/kernel/dmesg"sv, Core::File::OpenMode::Read)); 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 5de11b6db4..041ef2b4d5 100644 --- a/Userland/Utilities/du.cpp +++ b/Userland/Utilities/du.cpp @@ -11,6 +11,7 @@ #include <LibCore/ArgsParser.h> #include <LibCore/DateTime.h> #include <LibCore/DirIterator.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -116,7 +117,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& fi if (!pattern.is_empty()) 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 file = TRY(Core::File::open(exclude_from, Core::File::OpenMode::Read)); auto const buff = TRY(file->read_until_eof()); if (!buff.is_empty()) { DeprecatedString patterns = DeprecatedString::copy(buff, Chomp); diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp index da25e832ab..ecf71bb532 100644 --- a/Userland/Utilities/file.cpp +++ b/Userland/Utilities/file.cpp @@ -7,6 +7,7 @@ #include <AK/Vector.h> #include <LibCompress/Gzip.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/MappedFile.h> #include <LibCore/MimeData.h> #include <LibCore/Stream.h> @@ -158,7 +159,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto buffer = TRY(ByteBuffer::create_uninitialized(0x9006)); for (auto const& path : paths) { - auto file_or_error = Core::Stream::File::open(path, Core::Stream::OpenMode::Read); + auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read); if (file_or_error.is_error()) { perror(path.characters()); all_ok = false; diff --git a/Userland/Utilities/fortune.cpp b/Userland/Utilities/fortune.cpp index c641d3e4a0..f6da0e9631 100644 --- a/Userland/Utilities/fortune.cpp +++ b/Userland/Utilities/fortune.cpp @@ -12,6 +12,7 @@ #include <AK/Vector.h> #include <LibCore/ArgsParser.h> #include <LibCore/DateTime.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -81,7 +82,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(path, "Path to JSON file with quotes (/res/fortunes.json by default)", "path", Core::ArgsParser::Required::No); args_parser.parse(arguments); - auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); TRY(Core::System::unveil("/etc/timezone", "r")); TRY(Core::System::unveil(nullptr, nullptr)); diff --git a/Userland/Utilities/gml-format.cpp b/Userland/Utilities/gml-format.cpp index a332fb3051..ac4a7cbcbb 100644 --- a/Userland/Utilities/gml-format.cpp +++ b/Userland/Utilities/gml-format.cpp @@ -5,6 +5,7 @@ */ #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibGUI/GML/Formatter.h> @@ -13,8 +14,8 @@ static ErrorOr<bool> format_file(StringView path, bool inplace) { auto read_from_stdin = path == "-"; - 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 open_mode = (inplace && !read_from_stdin) ? Core::File::OpenMode::ReadWrite : Core::File::OpenMode::Read; + auto file = TRY(Core::File::open_file_or_standard_stream(path, open_mode)); auto contents = TRY(file->read_until_eof()); auto formatted_gml_or_error = GUI::GML::format_gml(contents); diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index 9004e841f6..31d8e00794 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -13,6 +13,7 @@ #include <LibCore/ArgsParser.h> #include <LibCore/DeprecatedFile.h> #include <LibCore/DirIterator.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -215,8 +216,8 @@ ErrorOr<int> serenity_main(Main::Arguments args) auto handle_file = [&matches, binary_mode, count_lines, quiet_mode, user_specified_multiple_files, &matched_line_count, &did_match_something](StringView filename, bool print_filename) -> ErrorOr<void> { - auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read)); - auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file))); + auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read)); + auto buffered_file = TRY(Core::BufferedFile::create(move(file))); for (size_t line_number = 1; TRY(buffered_file->can_read_line()); ++line_number) { Array<u8, PAGE_SIZE> buffer; diff --git a/Userland/Utilities/gron.cpp b/Userland/Utilities/gron.cpp index 925cc70fea..34721bec35 100644 --- a/Userland/Utilities/gron.cpp +++ b/Userland/Utilities/gron.cpp @@ -9,6 +9,7 @@ #include <AK/JsonValue.h> #include <AK/StringBuilder.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -54,7 +55,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(path, "Input", "input", Core::ArgsParser::Required::No); args_parser.parse(arguments); - auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read)); TRY(Core::System::pledge("stdio")); diff --git a/Userland/Utilities/gunzip.cpp b/Userland/Utilities/gunzip.cpp index 1c5b395b0f..531c753e3f 100644 --- a/Userland/Utilities/gunzip.cpp +++ b/Userland/Utilities/gunzip.cpp @@ -6,11 +6,12 @@ #include <LibCompress/Gzip.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/System.h> #include <LibMain/Main.h> #include <unistd.h> -static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::Stream::File> input_stream, AK::Stream& output_stream) +static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::File> input_stream, AK::Stream& output_stream) { auto gzip_stream = Compress::GzipDecompressor { move(input_stream) }; @@ -50,8 +51,8 @@ ErrorOr<int> serenity_main(Main::Arguments args) output_filename = filename; } - auto input_stream_result = TRY(Core::Stream::File::open(input_filename, Core::Stream::OpenMode::Read)); - auto output_stream = write_to_stdout ? TRY(Core::Stream::File::standard_output()) : TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write)); + auto input_stream_result = TRY(Core::File::open(input_filename, Core::File::OpenMode::Read)); + auto output_stream = write_to_stdout ? TRY(Core::File::standard_output()) : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write)); TRY(decompress_file(move(input_stream_result), *output_stream)); diff --git a/Userland/Utilities/gzip.cpp b/Userland/Utilities/gzip.cpp index 6f5aa5e230..28fbdc38c2 100644 --- a/Userland/Utilities/gzip.cpp +++ b/Userland/Utilities/gzip.cpp @@ -6,6 +6,7 @@ #include <LibCompress/Gzip.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/MappedFile.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -55,7 +56,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) else output_bytes = TRY(Compress::GzipCompressor::compress_all(input_bytes)); - auto output_stream = write_to_stdout ? TRY(Core::Stream::File::standard_output()) : TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write)); + 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)); if (!keep_input_files) { diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index c24754b3d8..43e2394e5e 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -694,7 +694,7 @@ static void load_page_for_screenshot_and_exit(HeadlessBrowserPageClient& page_cl if (Core::DeprecatedFile::exists(output_file_path)) MUST(Core::DeprecatedFile::remove(output_file_path, Core::DeprecatedFile::RecursionMode::Disallowed)); - auto output_file = MUST(Core::Stream::File::open(output_file_path, Core::Stream::OpenMode::Write)); + auto output_file = MUST(Core::File::open(output_file_path, Core::File::OpenMode::Write)); auto output_rect = page_client.screen_rect(); auto output_bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, output_rect.size().to_type<int>())); diff --git a/Userland/Utilities/hexdump.cpp b/Userland/Utilities/hexdump.cpp index 00fe33f4e1..008c46e2dc 100644 --- a/Userland/Utilities/hexdump.cpp +++ b/Userland/Utilities/hexdump.cpp @@ -7,6 +7,7 @@ #include <AK/Array.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -37,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments args) args_parser.add_option(seek_to, "Seek to a byte offset", "seek", 's', "offset"); args_parser.parse(args); - auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read)); if (seek_to.has_value()) TRY(file->seek(seek_to.value(), SeekMode::SetPosition)); diff --git a/Userland/Utilities/ifconfig.cpp b/Userland/Utilities/ifconfig.cpp index 5b8dc637a3..ad25907944 100644 --- a/Userland/Utilities/ifconfig.cpp +++ b/Userland/Utilities/ifconfig.cpp @@ -11,6 +11,7 @@ #include <AK/JsonObject.h> #include <AK/NumberFormat.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -31,7 +32,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.parse(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 = TRY(Core::File::open("/sys/kernel/net/adapters"sv, Core::File::OpenMode::Read)); auto file_contents = TRY(file->read_until_eof()); auto json = TRY(JsonValue::from_string(file_contents)); diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 3ca9af8d67..2528eb7b78 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -95,7 +95,7 @@ enum class PrintTarget { static ErrorOr<void> print(JS::Value value, PrintTarget target = PrintTarget::StandardOutput) { - auto stream = TRY(target == PrintTarget::StandardError ? Core::Stream::File::standard_error() : Core::Stream::File::standard_output()); + auto stream = TRY(target == PrintTarget::StandardError ? Core::File::standard_error() : Core::File::standard_output()); return print(value, *stream); } @@ -185,7 +185,7 @@ static ErrorOr<String> read_next_piece() static ErrorOr<void> write_to_file(String const& path) { - auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Write, 0666)); + auto file = TRY(Core::File::open(path, Core::File::OpenMode::Write, 0666)); 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) { @@ -334,7 +334,7 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm) auto& realm = *vm.current_realm(); auto filename = TRY(vm.argument(0).to_deprecated_string(vm)); - auto file_or_error = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read); + auto file_or_error = Core::File::open(filename, Core::File::OpenMode::Read); if (file_or_error.is_error()) return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error())); @@ -354,7 +354,7 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm) static JS::ThrowCompletionOr<JS::Value> load_json_impl(JS::VM& vm) { auto filename = TRY(vm.argument(0).to_string(vm)); - auto file_or_error = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read); + auto file_or_error = Core::File::open(filename, Core::File::OpenMode::Read); if (file_or_error.is_error()) return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error())); @@ -871,7 +871,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) warnln("Warning: Multiple files supplied, this will concatenate the sources and resolve modules as if it was the first file"); for (auto& path : script_paths) { - auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); auto file_contents = TRY(file->read_until_eof()); auto source = StringView { file_contents }; diff --git a/Userland/Utilities/json.cpp b/Userland/Utilities/json.cpp index d0653dc453..f8ce64e7bf 100644 --- a/Userland/Utilities/json.cpp +++ b/Userland/Utilities/json.cpp @@ -14,6 +14,7 @@ #include <AK/Types.h> #include <AK/Vector.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -43,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) VERIFY(spaces_in_indent >= 0); args_parser.parse(arguments); - auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read)); TRY(Core::System::pledge("stdio")); diff --git a/Userland/Utilities/lsblk.cpp b/Userland/Utilities/lsblk.cpp index e6d611ff45..443624b420 100644 --- a/Userland/Utilities/lsblk.cpp +++ b/Userland/Utilities/lsblk.cpp @@ -9,6 +9,7 @@ #include <AK/StringView.h> #include <LibCore/ArgsParser.h> #include <LibCore/DirIterator.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -38,19 +39,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) while (di.has_next()) { auto dir = di.next_path(); auto command_set_filename = DeprecatedString::formatted("/sys/devices/storage/{}/command_set", dir); - auto command_set_file = Core::Stream::File::open(command_set_filename, Core::Stream::OpenMode::Read); + auto command_set_file = Core::File::open(command_set_filename, Core::File::OpenMode::Read); if (command_set_file.is_error()) { dbgln("Error: Could not open {}: {}", command_set_filename, command_set_file.error()); continue; } auto last_lba_filename = DeprecatedString::formatted("/sys/devices/storage/{}/last_lba", dir); - auto last_lba_file = Core::Stream::File::open(last_lba_filename, Core::Stream::OpenMode::Read); + auto last_lba_file = Core::File::open(last_lba_filename, Core::File::OpenMode::Read); if (last_lba_file.is_error()) { dbgln("Error: Could not open {}: {}", last_lba_filename, last_lba_file.error()); continue; } auto sector_size_filename = DeprecatedString::formatted("/sys/devices/storage/{}/sector_size", dir); - auto sector_size_file = Core::Stream::File::open(sector_size_filename, Core::Stream::OpenMode::Read); + auto sector_size_file = Core::File::open(sector_size_filename, Core::File::OpenMode::Read); if (sector_size_file.is_error()) { dbgln("Error: Could not open {}: {}", sector_size_filename, sector_size_file.error()); continue; diff --git a/Userland/Utilities/lscpu.cpp b/Userland/Utilities/lscpu.cpp index 4a9f143c78..21b00cc492 100644 --- a/Userland/Utilities/lscpu.cpp +++ b/Userland/Utilities/lscpu.cpp @@ -9,6 +9,7 @@ #include <AK/JsonArray.h> #include <AK/JsonObject.h> #include <AK/NumberFormat.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -59,7 +60,7 @@ ErrorOr<int> serenity_main(Main::Arguments) TRY(Core::System::unveil("/sys/kernel/cpuinfo", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto file = TRY(Core::Stream::File::open("/sys/kernel/cpuinfo"sv, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open("/sys/kernel/cpuinfo"sv, Core::File::OpenMode::Read)); 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 b572563905..55dc1c34b0 100644 --- a/Userland/Utilities/lsirq.cpp +++ b/Userland/Utilities/lsirq.cpp @@ -7,6 +7,7 @@ #include <AK/JsonArray.h> #include <AK/JsonObject.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -17,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments) TRY(Core::System::unveil("/sys/kernel/interrupts", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto proc_interrupts = TRY(Core::Stream::File::open("/sys/kernel/interrupts"sv, Core::Stream::OpenMode::Read)); + auto proc_interrupts = TRY(Core::File::open("/sys/kernel/interrupts"sv, Core::File::OpenMode::Read)); TRY(Core::System::pledge("stdio")); diff --git a/Userland/Utilities/lsjails.cpp b/Userland/Utilities/lsjails.cpp index 7f0fb392cb..06b6d02fd3 100644 --- a/Userland/Utilities/lsjails.cpp +++ b/Userland/Utilities/lsjails.cpp @@ -6,6 +6,7 @@ #include <AK/JsonArray.h> #include <AK/JsonObject.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -16,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments) TRY(Core::System::unveil("/sys/kernel/jails", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto jails_data = TRY(Core::Stream::File::open("/sys/kernel/jails"sv, Core::Stream::OpenMode::Read)); + auto jails_data = TRY(Core::File::open("/sys/kernel/jails"sv, Core::File::OpenMode::Read)); TRY(Core::System::pledge("stdio")); diff --git a/Userland/Utilities/lsof.cpp b/Userland/Utilities/lsof.cpp index c59d5922cb..cc7901fab8 100644 --- a/Userland/Utilities/lsof.cpp +++ b/Userland/Utilities/lsof.cpp @@ -11,6 +11,7 @@ #include <AK/JsonValue.h> #include <AK/Vector.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/ProcessStatisticsReader.h> #include <LibCore/Stream.h> #include <LibCore/System.h> @@ -65,7 +66,7 @@ static bool parse_name(StringView name, OpenFile& file) static Vector<OpenFile> get_open_files_by_pid(pid_t pid) { - auto file = Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/fds", pid), Core::Stream::OpenMode::Read); + auto file = Core::File::open(DeprecatedString::formatted("/proc/{}/fds", pid), Core::File::OpenMode::Read); if (file.is_error()) { outln("lsof: PID {}: {}", pid, file.error()); return Vector<OpenFile>(); diff --git a/Userland/Utilities/lspci.cpp b/Userland/Utilities/lspci.cpp index feac6a4ae6..6f97cf5414 100644 --- a/Userland/Utilities/lspci.cpp +++ b/Userland/Utilities/lspci.cpp @@ -13,6 +13,7 @@ #include <AK/StringView.h> #include <LibCore/ArgsParser.h> #include <LibCore/DirIterator.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -89,31 +90,31 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto function = convert_sysfs_value_to_uint(function_parts[1]); auto vendor_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/vendor", dir); - auto vendor_id_file = Core::Stream::File::open(vendor_id_filename, Core::Stream::OpenMode::Read); + auto vendor_id_file = Core::File::open(vendor_id_filename, Core::File::OpenMode::Read); if (vendor_id_file.is_error()) { dbgln("Error: Could not open {}: {}", vendor_id_filename, vendor_id_file.error()); continue; } auto device_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/device_id", dir); - auto device_id_file = Core::Stream::File::open(device_id_filename, Core::Stream::OpenMode::Read); + auto device_id_file = Core::File::open(device_id_filename, Core::File::OpenMode::Read); if (device_id_file.is_error()) { dbgln("Error: Could not open {}: {}", device_id_filename, device_id_file.error()); continue; } auto class_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/class", dir); - auto class_id_file = Core::Stream::File::open(class_id_filename, Core::Stream::OpenMode::Read); + auto class_id_file = Core::File::open(class_id_filename, Core::File::OpenMode::Read); if (class_id_file.is_error()) { dbgln("Error: Could not open {}: {}", class_id_filename, class_id_file.error()); continue; } auto subclass_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/subclass", dir); - auto subclass_id_file = Core::Stream::File::open(subclass_id_filename, Core::Stream::OpenMode::Read); + auto subclass_id_file = Core::File::open(subclass_id_filename, Core::File::OpenMode::Read); if (subclass_id_file.is_error()) { dbgln("Error: Could not open {}: {}", subclass_id_filename, subclass_id_file.error()); continue; } auto revision_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/revision", dir); - auto revision_id_file = Core::Stream::File::open(revision_id_filename, Core::Stream::OpenMode::Read); + auto revision_id_file = Core::File::open(revision_id_filename, Core::File::OpenMode::Read); if (revision_id_file.is_error()) { dbgln("Error: Could not open {}: {}", revision_id_filename, revision_id_file.error()); continue; @@ -177,7 +178,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) continue; for (size_t bar_index = 0; bar_index <= 5; bar_index++) { auto bar_value_filename = DeprecatedString::formatted("/sys/bus/pci/{}/bar{}", dir, bar_index); - auto bar_value_file = Core::Stream::File::open(bar_value_filename, Core::Stream::OpenMode::Read); + auto bar_value_file = Core::File::open(bar_value_filename, Core::File::OpenMode::Read); if (bar_value_file.is_error()) { dbgln("Error: Could not open {}: {}", bar_value_filename, bar_value_file.error()); continue; diff --git a/Userland/Utilities/lsusb.cpp b/Userland/Utilities/lsusb.cpp index 5f4806b96c..a3eeeb8796 100644 --- a/Userland/Utilities/lsusb.cpp +++ b/Userland/Utilities/lsusb.cpp @@ -12,6 +12,7 @@ #include <AK/LexicalPath.h> #include <LibCore/ArgsParser.h> #include <LibCore/DirIterator.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -48,7 +49,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) while (usb_devices.has_next()) { auto full_path = LexicalPath(usb_devices.next_full_path()); - auto proc_usb_device = Core::Stream::File::open(full_path.string(), Core::Stream::OpenMode::Read); + auto proc_usb_device = Core::File::open(full_path.string(), Core::File::OpenMode::Read); if (proc_usb_device.is_error()) { warnln("Failed to open {}: {}", full_path.string(), proc_usb_device.error()); continue; diff --git a/Userland/Utilities/man.cpp b/Userland/Utilities/man.cpp index 80546b0e6b..95d365019c 100644 --- a/Userland/Utilities/man.cpp +++ b/Userland/Utilities/man.cpp @@ -9,6 +9,7 @@ #include <AK/DeprecatedString.h> #include <AK/Utf8View.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -84,7 +85,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) .to_deprecated_string(); pid_t pager_pid = TRY(pipe_to_pager(pager)); - auto file = TRY(Core::Stream::File::open(TRY(page->path()), Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open(TRY(page->path()), Core::File::OpenMode::Read)); TRY(Core::System::pledge("stdio proc")); diff --git a/Userland/Utilities/markdown-check.cpp b/Userland/Utilities/markdown-check.cpp index 55c45d2d75..549a18f272 100644 --- a/Userland/Utilities/markdown-check.cpp +++ b/Userland/Utilities/markdown-check.cpp @@ -20,6 +20,7 @@ #include <AK/Vector.h> #include <LibCore/ArgsParser.h> #include <LibCore/DeprecatedFile.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibMain/Main.h> #include <LibMarkdown/Document.h> @@ -249,7 +250,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) outln("Reading and parsing Markdown files ..."); HashMap<DeprecatedString, MarkdownLinkage> files; for (auto path : file_paths) { - auto file_or_error = Core::Stream::File::open(path, Core::Stream::OpenMode::Read); + auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read); if (file_or_error.is_error()) { warnln("Failed to open {}: {}", 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 a027043219..6c28fc31f9 100644 --- a/Userland/Utilities/md.cpp +++ b/Userland/Utilities/md.cpp @@ -6,6 +6,7 @@ #include <AK/DeprecatedString.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -41,7 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } } - auto file = TRY(Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read)); TRY(Core::System::pledge("stdio")); diff --git a/Userland/Utilities/mount.cpp b/Userland/Utilities/mount.cpp index e1d91b4146..3b6f9f323d 100644 --- a/Userland/Utilities/mount.cpp +++ b/Userland/Utilities/mount.cpp @@ -9,6 +9,7 @@ #include <AK/JsonValue.h> #include <LibCore/ArgsParser.h> #include <LibCore/DirIterator.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -112,8 +113,8 @@ static ErrorOr<void> mount_all() bool all_ok = true; auto process_fstab_entries = [&](StringView path) -> ErrorOr<void> { - auto file_unbuffered = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); - auto file = TRY(Core::Stream::BufferedFile::create(move(file_unbuffered))); + auto file_unbuffered = TRY(Core::File::open(path, Core::File::OpenMode::Read)); + auto file = TRY(Core::BufferedFile::create(move(file_unbuffered))); while (TRY(file->can_read_line())) { auto line = TRY(file->read_line(buffer)); @@ -148,7 +149,7 @@ static ErrorOr<void> mount_all() 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 df = TRY(Core::File::open("/sys/kernel/df"sv, Core::File::OpenMode::Read)); auto content = TRY(df->read_until_eof()); auto json = TRY(JsonValue::from_string(content)); diff --git a/Userland/Utilities/netstat.cpp b/Userland/Utilities/netstat.cpp index 0f5038591e..6e99860a45 100644 --- a/Userland/Utilities/netstat.cpp +++ b/Userland/Utilities/netstat.cpp @@ -11,6 +11,7 @@ #include <AK/JsonObject.h> #include <AK/QuickSort.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/ProcessStatisticsReader.h> #include <LibCore/Stream.h> #include <LibCore/System.h> @@ -154,7 +155,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 = TRY(Core::File::open("/sys/kernel/net/tcp"sv, Core::File::OpenMode::Read)); auto file_contents = TRY(file->read_until_eof()); auto json_or_error = JsonValue::from_string(file_contents); if (json_or_error.is_error()) { @@ -246,7 +247,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 = TRY(Core::File::open("/sys/kernel/net/udp"sv, Core::File::OpenMode::Read)); auto file_contents = TRY(file->read_until_eof()); auto json = TRY(JsonValue::from_string(file_contents)); diff --git a/Userland/Utilities/nologin.cpp b/Userland/Utilities/nologin.cpp index 8c187d9764..c28572c626 100644 --- a/Userland/Utilities/nologin.cpp +++ b/Userland/Utilities/nologin.cpp @@ -5,6 +5,7 @@ */ #include <AK/StringView.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -13,7 +14,7 @@ ErrorOr<int> serenity_main(Main::Arguments) { TRY(Core::System::pledge("stdio rpath"sv)); - auto file_or_error = Core::Stream::File::open("/etc/nologin"sv, Core::Stream::OpenMode::Read); + auto file_or_error = Core::File::open("/etc/nologin"sv, Core::File::OpenMode::Read); if (file_or_error.is_error()) { outln("This account is currently not available."); } else { diff --git a/Userland/Utilities/nproc.cpp b/Userland/Utilities/nproc.cpp index 54f730fe7a..4d8eccc00b 100644 --- a/Userland/Utilities/nproc.cpp +++ b/Userland/Utilities/nproc.cpp @@ -5,6 +5,7 @@ */ #include <AK/JsonObject.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -12,7 +13,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 file = TRY(Core::File::open("/sys/kernel/cpuinfo"sv, Core::File::OpenMode::Read)); auto buffer = TRY(file->read_until_eof()); auto json = TRY(JsonValue::from_string(buffer)); diff --git a/Userland/Utilities/pmap.cpp b/Userland/Utilities/pmap.cpp index 7a95a43231..49bb7d8153 100644 --- a/Userland/Utilities/pmap.cpp +++ b/Userland/Utilities/pmap.cpp @@ -8,6 +8,7 @@ #include <AK/JsonObject.h> #include <AK/QuickSort.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -26,7 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(pid, "PID", "PID", Core::ArgsParser::Required::Yes); args_parser.parse(arguments); - auto file = TRY(Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/vm", pid), Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open(DeprecatedString::formatted("/proc/{}/vm", pid), Core::File::OpenMode::Read)); outln("{}:", pid); diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp index 0f8b8dda3b..150f80394d 100644 --- a/Userland/Utilities/pro.cpp +++ b/Userland/Utilities/pro.cpp @@ -242,7 +242,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) RefPtr<Protocol::Request> request; auto protocol_client = TRY(Protocol::RequestClient::try_create()); - auto output_stream = ConditionalOutputStream { [&] { return should_save_stream_data; }, TRY(Core::Stream::File::adopt_fd(output_fd, Core::Stream::OpenMode::Write)) }; + auto output_stream = ConditionalOutputStream { [&] { return should_save_stream_data; }, TRY(Core::File::adopt_fd(output_fd, Core::File::OpenMode::Write)) }; // https://httpwg.org/specs/rfc9110.html#authentication auto const has_credentials = !credentials.is_empty(); diff --git a/Userland/Utilities/reboot.cpp b/Userland/Utilities/reboot.cpp index 2c24c9b225..2aea62645b 100644 --- a/Userland/Utilities/reboot.cpp +++ b/Userland/Utilities/reboot.cpp @@ -5,12 +5,13 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibMain/Main.h> ErrorOr<int> serenity_main(Main::Arguments) { - auto file = TRY(Core::Stream::File::open("/sys/kernel/power_state"sv, Core::Stream::OpenMode::Write)); + 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())); diff --git a/Userland/Utilities/route.cpp b/Userland/Utilities/route.cpp index 93c89a0167..84fe136dcd 100644 --- a/Userland/Utilities/route.cpp +++ b/Userland/Utilities/route.cpp @@ -11,6 +11,7 @@ #include <AK/QuickSort.h> #include <AK/StringView.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/ProcessStatisticsReader.h> #include <LibCore/Stream.h> #include <LibCore/System.h> @@ -89,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 = TRY(Core::File::open("/sys/kernel/net/route"sv, Core::File::OpenMode::Read)); auto file_contents = TRY(file->read_until_eof()); auto json = TRY(JsonValue::from_string(file_contents)); diff --git a/Userland/Utilities/sed.cpp b/Userland/Utilities/sed.cpp index d25dd969a7..cd1d4363e2 100644 --- a/Userland/Utilities/sed.cpp +++ b/Userland/Utilities/sed.cpp @@ -8,6 +8,7 @@ #include <AK/GenericLexer.h> #include <AK/Vector.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -116,17 +117,17 @@ ErrorOr<int> serenity_main(Main::Arguments args) auto command = TRY(parse_command(command_input)); - Optional<NonnullOwnPtr<Core::Stream::File>> maybe_output_file; + Optional<NonnullOwnPtr<Core::File>> maybe_output_file; if (command.output_filepath.has_value()) - maybe_output_file = TRY(Core::Stream::File::open_file_or_standard_stream(command.output_filepath.release_value(), Core::Stream::OpenMode::Write)); + maybe_output_file = TRY(Core::File::open_file_or_standard_stream(command.output_filepath.release_value(), Core::File::OpenMode::Write)); if (filepaths.is_empty()) filepaths = { "-"sv }; Array<u8, PAGE_SIZE> buffer {}; for (auto const& filepath : filepaths) { - auto file_unbuffered = TRY(Core::Stream::File::open_file_or_standard_stream(filepath, Core::Stream::OpenMode::Read)); - auto file = TRY(Core::Stream::BufferedFile::create(move(file_unbuffered))); + auto file_unbuffered = TRY(Core::File::open_file_or_standard_stream(filepath, Core::File::OpenMode::Read)); + auto file = TRY(Core::BufferedFile::create(move(file_unbuffered))); while (!file->is_eof()) { auto line = TRY(file->read_line(buffer)); diff --git a/Userland/Utilities/shot.cpp b/Userland/Utilities/shot.cpp index 3ecbfff3cb..f39f8df362 100644 --- a/Userland/Utilities/shot.cpp +++ b/Userland/Utilities/shot.cpp @@ -161,7 +161,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (edit_image) output_path = Core::DateTime::now().to_deprecated_string("/tmp/screenshot-%Y-%m-%d-%H-%M-%S.png"sv); - auto file_or_error = Core::Stream::File::open(output_path, Core::Stream::OpenMode::ReadWrite); + auto file_or_error = Core::File::open(output_path, Core::File::OpenMode::ReadWrite); if (file_or_error.is_error()) { warnln("Could not open '{}' for writing: {}", output_path, file_or_error.error()); return 1; diff --git a/Userland/Utilities/shuf.cpp b/Userland/Utilities/shuf.cpp index 30a1c9f379..1b0c94bf99 100644 --- a/Userland/Utilities/shuf.cpp +++ b/Userland/Utilities/shuf.cpp @@ -9,6 +9,7 @@ #include <AK/Random.h> #include <AK/Vector.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -28,7 +29,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)); + auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read)); ByteBuffer buffer = TRY(file->read_until_eof()); u8 input_delimiter = is_zero_terminated ? '\0' : '\n'; diff --git a/Userland/Utilities/shutdown.cpp b/Userland/Utilities/shutdown.cpp index 5555ba3693..968e88e835 100644 --- a/Userland/Utilities/shutdown.cpp +++ b/Userland/Utilities/shutdown.cpp @@ -6,6 +6,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibMain/Main.h> #include <fcntl.h> @@ -14,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments) { - auto file = TRY(Core::Stream::File::open("/sys/kernel/power_state"sv, Core::Stream::OpenMode::Write)); + 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())); diff --git a/Userland/Utilities/sort.cpp b/Userland/Utilities/sort.cpp index 46d0a9ca80..d91cbf3d08 100644 --- a/Userland/Utilities/sort.cpp +++ b/Userland/Utilities/sort.cpp @@ -9,6 +9,7 @@ #include <AK/QuickSort.h> #include <AK/Vector.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -60,8 +61,8 @@ struct Options { static ErrorOr<void> load_file(Options options, StringView filename, Vector<Line>& lines, HashTable<Line>& seen) { - auto file = TRY(Core::Stream::BufferedFile::create( - TRY(Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read)))); + auto file = TRY(Core::BufferedFile::create( + TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read)))); // FIXME: Unlimited line length auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); diff --git a/Userland/Utilities/sql.cpp b/Userland/Utilities/sql.cpp index 9158cc793e..31be2c664f 100644 --- a/Userland/Utilities/sql.cpp +++ b/Userland/Utilities/sql.cpp @@ -152,7 +152,7 @@ private: NonnullRefPtr<SQL::SQLClient> m_sql_client; SQL::ConnectionID m_connection_id { 0 }; Core::EventLoop& m_loop; - OwnPtr<Core::Stream::BufferedFile> m_input_file { nullptr }; + OwnPtr<Core::BufferedFile> m_input_file { nullptr }; bool m_quit_when_files_read { false }; Vector<DeprecatedString> m_input_file_chain {}; Array<u8, 4096> m_buffer {}; @@ -161,13 +161,13 @@ private: { if (!m_input_file && !m_input_file_chain.is_empty()) { auto file_name = m_input_file_chain.take_first(); - auto file_or_error = Core::Stream::File::open(file_name, Core::Stream::OpenMode::Read); + auto file_or_error = Core::File::open(file_name, Core::File::OpenMode::Read); if (file_or_error.is_error()) { warnln("Input file {} could not be opened: {}", file_name, file_or_error.error()); return {}; } - auto buffered_file_or_error = Core::Stream::BufferedFile::create(file_or_error.release_value()); + auto buffered_file_or_error = Core::BufferedFile::create(file_or_error.release_value()); if (buffered_file_or_error.is_error()) { warnln("Input file {} could not be buffered: {}", file_name, buffered_file_or_error.error()); return {}; diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp index 1996e5d12d..a20ae8a55a 100644 --- a/Userland/Utilities/strace.cpp +++ b/Userland/Utilities/strace.cpp @@ -11,6 +11,7 @@ #include <AK/Types.h> #include <Kernel/API/SyscallString.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -836,8 +837,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) parser.parse(arguments); auto trace_file = output_filename.is_empty() - ? TRY(Core::Stream::File::standard_error()) - : TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write)); + ? TRY(Core::File::standard_error()) + : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write)); auto parse_syscalls = [](char const* option, auto& hash_table) { if (option != nullptr) { diff --git a/Userland/Utilities/strings.cpp b/Userland/Utilities/strings.cpp index 531db31838..2fb364c97f 100644 --- a/Userland/Utilities/strings.cpp +++ b/Userland/Utilities/strings.cpp @@ -7,6 +7,7 @@ #include <AK/CharacterTypes.h> #include <AK/Forward.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -67,7 +68,7 @@ static ErrorOr<void> process_strings_in_file(StringView path, bool show_paths, S { Array<u8, buffer_read_size> buffer; Vector<u8> output_characters; - auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read)); size_t processed_characters = 0; size_t string_offset_position = 0; bool did_show_path = false; diff --git a/Userland/Utilities/sysctl.cpp b/Userland/Utilities/sysctl.cpp index c234edbf85..3834f9aa12 100644 --- a/Userland/Utilities/sysctl.cpp +++ b/Userland/Utilities/sysctl.cpp @@ -7,6 +7,7 @@ #include <LibCore/ArgsParser.h> #include <LibCore/DirIterator.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibMain/Main.h> @@ -15,7 +16,7 @@ static bool s_set_variable = false; static DeprecatedString get_variable(StringView name) { auto path = DeprecatedString::formatted("/sys/kernel/variables/{}", name); - auto file = Core::Stream::File::open(path, Core::Stream::OpenMode::Read); + auto file = Core::File::open(path, Core::File::OpenMode::Read); if (file.is_error()) { warnln("Failed to open {}: {}", path, file.error()); return {}; @@ -43,7 +44,7 @@ static bool write_variable(StringView name, StringView value) if (old_value.is_null()) return false; auto path = DeprecatedString::formatted("/sys/kernel/variables/{}", name); - auto file = Core::Stream::File::open(path, Core::Stream::OpenMode::Write); + auto file = Core::File::open(path, Core::File::OpenMode::Write); if (file.is_error()) { warnln("Failed to open {}: {}", path, file.error()); return false; diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp index 96b5fe0234..658c4aba34 100644 --- a/Userland/Utilities/tail.cpp +++ b/Userland/Utilities/tail.cpp @@ -6,13 +6,14 @@ #include <LibCore/ArgsParser.h> #include <LibCore/EventLoop.h> +#include <LibCore/File.h> #include <LibCore/FileWatcher.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #define DEFAULT_LINE_COUNT 10 -static ErrorOr<void> tail_from_pos(Core::Stream::File& file, off_t startline) +static ErrorOr<void> tail_from_pos(Core::File& file, off_t startline) { TRY(file.seek(startline + 1, SeekMode::SetPosition)); auto buffer = TRY(file.read_until_eof()); @@ -20,7 +21,7 @@ static ErrorOr<void> tail_from_pos(Core::Stream::File& file, off_t startline) return {}; } -static ErrorOr<off_t> find_seek_pos(Core::Stream::File& file, int wanted_lines) +static ErrorOr<off_t> find_seek_pos(Core::File& file, int wanted_lines) { // Rather than reading the whole file, start at the end and work backwards, // stopping when we've found the number of lines we want. @@ -61,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(file, "File path", "file", Core::ArgsParser::Required::No); args_parser.parse(arguments); - auto f = TRY(Core::Stream::File::open_file_or_standard_stream(file, Core::Stream::OpenMode::Read)); + auto f = TRY(Core::File::open_file_or_standard_stream(file, Core::File::OpenMode::Read)); if (!follow) TRY(Core::System::pledge("stdio")); diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp index c7af350005..2a156b9d02 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -64,7 +64,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!directory.is_empty()) TRY(Core::System::chdir(directory)); - NonnullOwnPtr<AK::Stream> input_stream = TRY(Core::Stream::File::open_file_or_standard_stream(archive_file, Core::Stream::OpenMode::Read)); + NonnullOwnPtr<AK::Stream> input_stream = TRY(Core::File::open_file_or_standard_stream(archive_file, Core::File::OpenMode::Read)); if (gzip) input_stream = make<Compress::GzipDecompressor>(move(input_stream)); @@ -206,10 +206,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 1; } - NonnullOwnPtr<AK::Stream> output_stream = TRY(Core::Stream::File::standard_output()); + NonnullOwnPtr<AK::Stream> output_stream = TRY(Core::File::standard_output()); if (!archive_file.is_empty()) - output_stream = TRY(Core::Stream::File::open(archive_file, Core::Stream::OpenMode::Write)); + output_stream = TRY(Core::File::open(archive_file, Core::File::OpenMode::Write)); if (!directory.is_empty()) TRY(Core::System::chdir(directory)); diff --git a/Userland/Utilities/test-fuzz.cpp b/Userland/Utilities/test-fuzz.cpp index a7539d1774..8f01380dd0 100644 --- a/Userland/Utilities/test-fuzz.cpp +++ b/Userland/Utilities/test-fuzz.cpp @@ -6,6 +6,7 @@ #include <AK/DeprecatedString.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibMain/Main.h> #include <unistd.h> @@ -156,7 +157,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 file = TRY(Core::File::open(filename, Core::File::OpenMode::Read)); auto input = TRY(file->read_until_eof()); return fn(input.data(), input.size()); diff --git a/Userland/Utilities/tsort.cpp b/Userland/Utilities/tsort.cpp index 201e063698..f51b2f96f6 100644 --- a/Userland/Utilities/tsort.cpp +++ b/Userland/Utilities/tsort.cpp @@ -7,6 +7,7 @@ #include <AK/CharacterTypes.h> #include <AK/HashMap.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -103,7 +104,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_option(quiet, "Suppress warnings about cycles", "quiet", 'q'); args_parser.parse(arguments); - auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read)); auto input_bytes = TRY(file->read_until_eof()); auto inputs = StringView(input_bytes).split_view_if(is_ascii_space); diff --git a/Userland/Utilities/uniq.cpp b/Userland/Utilities/uniq.cpp index c8166e4968..35b502e4c8 100644 --- a/Userland/Utilities/uniq.cpp +++ b/Userland/Utilities/uniq.cpp @@ -8,11 +8,12 @@ #include <AK/RefPtr.h> #include <AK/StringView.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <unistd.h> -static ErrorOr<void> write_line_content(StringView line, size_t count, bool duplicates_only, bool print_count, Core::Stream::File& outfile) +static ErrorOr<void> write_line_content(StringView line, size_t count, bool duplicates_only, bool print_count, Core::File& outfile) { if (duplicates_only && count <= 1) return {}; @@ -79,8 +80,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 0; } - auto infile = TRY(Core::Stream::BufferedFile::create(TRY(Core::Stream::File::open_file_or_standard_stream(inpath, Core::Stream::OpenMode::Read)))); - auto outfile = TRY(Core::Stream::File::open_file_or_standard_stream(outpath, Core::Stream::OpenMode::Write)); + auto infile = TRY(Core::BufferedFile::create(TRY(Core::File::open_file_or_standard_stream(inpath, Core::File::OpenMode::Read)))); + auto outfile = TRY(Core::File::open_file_or_standard_stream(outpath, Core::File::OpenMode::Write)); size_t count = 0; ByteBuffer previous_buf = TRY(ByteBuffer::create_uninitialized(1024)); diff --git a/Userland/Utilities/uptime.cpp b/Userland/Utilities/uptime.cpp index 265fda6be5..f70cdaf8c4 100644 --- a/Userland/Utilities/uptime.cpp +++ b/Userland/Utilities/uptime.cpp @@ -6,6 +6,7 @@ */ #include <AK/NumberFormat.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -14,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments) { TRY(Core::System::pledge("stdio rpath")); - auto file = TRY(Core::Stream::File::open("/sys/kernel/uptime"sv, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open("/sys/kernel/uptime"sv, Core::File::OpenMode::Read)); TRY(Core::System::pledge("stdio")); diff --git a/Userland/Utilities/utmpupdate.cpp b/Userland/Utilities/utmpupdate.cpp index cc7e282488..0bca719706 100644 --- a/Userland/Utilities/utmpupdate.cpp +++ b/Userland/Utilities/utmpupdate.cpp @@ -10,6 +10,7 @@ #include <AK/JsonValue.h> #include <LibCore/ArgsParser.h> #include <LibCore/DateTime.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -42,7 +43,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) dbgln("Updating utmp from UID={} GID={} EGID={} PID={}", getuid(), getgid(), getegid(), pid); - auto file = TRY(Core::Stream::File::open("/var/run/utmp"sv, Core::Stream::OpenMode::ReadWrite)); + auto file = TRY(Core::File::open("/var/run/utmp"sv, Core::File::OpenMode::ReadWrite)); auto file_contents = TRY(file->read_until_eof()); auto previous_json = TRY(JsonValue::from_string(file_contents)); diff --git a/Userland/Utilities/w.cpp b/Userland/Utilities/w.cpp index 96f3854b2d..e92f791055 100644 --- a/Userland/Utilities/w.cpp +++ b/Userland/Utilities/w.cpp @@ -7,6 +7,7 @@ #include <AK/JsonObject.h> #include <AK/JsonValue.h> #include <LibCore/DateTime.h> +#include <LibCore/File.h> #include <LibCore/ProcessStatisticsReader.h> #include <LibCore/Stream.h> #include <LibCore/System.h> @@ -25,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments) TRY(Core::System::unveil("/sys/kernel/processes", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto file = TRY(Core::Stream::File::open("/var/run/utmp"sv, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open("/var/run/utmp"sv, Core::File::OpenMode::Read)); auto file_contents = TRY(file->read_until_eof()); auto json = TRY(JsonValue::from_string(file_contents)); if (!json.is_object()) { diff --git a/Userland/Utilities/wasm.cpp b/Userland/Utilities/wasm.cpp index 5dababeb10..d82ff82fa2 100644 --- a/Userland/Utilities/wasm.cpp +++ b/Userland/Utilities/wasm.cpp @@ -7,6 +7,7 @@ #include <AK/MemoryStream.h> #include <LibCore/ArgsParser.h> +#include <LibCore/File.h> #include <LibCore/MappedFile.h> #include <LibLine/Editor.h> #include <LibMain/Main.h> @@ -338,7 +339,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!parse_result.has_value()) return 1; - g_stdout = TRY(Core::Stream::File::standard_output()); + g_stdout = TRY(Core::File::standard_output()); g_printer = TRY(try_make<Wasm::Printer>(*g_stdout)); if (print && !attempt_instantiate) { diff --git a/Userland/Utilities/xml.cpp b/Userland/Utilities/xml.cpp index 7be705dd6a..78796142c5 100644 --- a/Userland/Utilities/xml.cpp +++ b/Userland/Utilities/xml.cpp @@ -10,6 +10,7 @@ #include <AK/URLParser.h> #include <LibCore/ArgsParser.h> #include <LibCore/DeprecatedFile.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibMain/Main.h> #include <LibXML/DOM/Document.h> @@ -371,7 +372,7 @@ static auto parse(StringView contents) if (url.scheme() != "file") return Error::from_string_literal("NYI: Nonlocal entity"); - auto file = TRY(Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open(url.path(), Core::File::OpenMode::Read)); return DeprecatedString::copy(TRY(file->read_until_eof())); }, }, @@ -440,7 +441,7 @@ static void do_run_tests(XML::Document& document) continue; } - auto file_result = Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read); + auto file_result = Core::File::open(url.path(), Core::File::OpenMode::Read); if (file_result.is_error()) { warnln("Read error for {}: {}", url.path(), file_result.error()); s_test_results.set(url.path(), TestResult::RunnerFailed); @@ -468,7 +469,7 @@ static void do_run_tests(XML::Document& document) auto out = suite.attributes.find("OUTPUT"); if (out != suite.attributes.end()) { auto out_path = LexicalPath::join(test_base_path, out->value).string(); - auto file_result = Core::Stream::File::open(out_path, Core::Stream::OpenMode::Read); + auto file_result = Core::File::open(out_path, Core::File::OpenMode::Read); if (file_result.is_error()) { warnln("Read error for {}: {}", out_path, file_result.error()); s_test_results.set(url.path(), TestResult::RunnerFailed); @@ -516,7 +517,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) parser.parse(arguments); s_path = Core::DeprecatedFile::real_path_for(filename); - auto file = TRY(Core::Stream::File::open(s_path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open(s_path, Core::File::OpenMode::Read)); auto contents = TRY(file->read_until_eof()); auto xml_parser = parse(contents); diff --git a/Userland/Utilities/zip.cpp b/Userland/Utilities/zip.cpp index 7a9b88deff..12679b67e0 100644 --- a/Userland/Utilities/zip.cpp +++ b/Userland/Utilities/zip.cpp @@ -12,6 +12,7 @@ #include <LibCore/DateTime.h> #include <LibCore/DeprecatedFile.h> #include <LibCore/DirIterator.h> +#include <LibCore/File.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibCrypto/Checksum/CRC32.h> @@ -50,12 +51,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } outln("Archive: {}", zip_file_path); - auto file_stream = TRY(Core::Stream::File::open(zip_file_path, Core::Stream::OpenMode::Write)); + auto file_stream = TRY(Core::File::open(zip_file_path, Core::File::OpenMode::Write)); Archive::ZipOutputStream zip_stream(move(file_stream)); auto add_file = [&](DeprecatedString path) -> ErrorOr<void> { auto canonicalized_path = LexicalPath::canonicalized_path(path); - auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); + auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); auto file_buffer = TRY(file->read_until_eof()); Archive::ZipMember member {}; member.name = TRY(String::from_deprecated_string(canonicalized_path)); |