diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2023-05-03 18:45:18 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-09 11:18:46 +0200 |
commit | 8c34959b53b2b72122fe6d2718d5dc060ff56875 (patch) | |
tree | 8e88ecd303fddce25ffc170d297bc76762f115da /Userland | |
parent | 48b000a36cb22550e2c5314bc6c471812c963d0c (diff) | |
download | serenity-8c34959b53b2b72122fe6d2718d5dc060ff56875.zip |
AK: Add the `Input` word to input-only buffered streams
This concerns both `BufferedSeekable` and `BufferedFile`.
Diffstat (limited to 'Userland')
35 files changed, 51 insertions, 52 deletions
diff --git a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp index 6b0720e4b1..a2c0b3943c 100644 --- a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp +++ b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp @@ -19,7 +19,7 @@ static inline GLuint get_index_value(StringView& representation) ErrorOr<NonnullRefPtr<Mesh>> WavefrontOBJLoader::load(String const& filename, NonnullOwnPtr<Core::File> file) { - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); Vector<Vertex> vertices; Vector<Vertex> normals; diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index 6a8127c32d..a9c30e0f13 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -48,7 +48,7 @@ DeprecatedString g_webdriver_content_ipc_path; static ErrorOr<void> load_content_filters() { auto file = TRY(Core::File::open(TRY(String::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory())), Core::File::OpenMode::Read)); - auto ad_filter_list = TRY(Core::BufferedFile::create(move(file))); + auto ad_filter_list = TRY(Core::InputBufferedFile::create(move(file))); auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); Browser::g_content_filters.clear_with_capacity(); @@ -68,7 +68,7 @@ static ErrorOr<void> load_content_filters() static ErrorOr<void> load_autoplay_allowlist() { auto file = TRY(Core::File::open(TRY(String::formatted("{}/BrowserAutoplayAllowlist.txt", Core::StandardPaths::config_directory())), Core::File::OpenMode::Read)); - auto allowlist = TRY(Core::BufferedFile::create(move(file))); + auto allowlist = TRY(Core::InputBufferedFile::create(move(file))); auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); Browser::g_autoplay_allowlist.clear_with_capacity(); diff --git a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp index 7ea4c723cc..116c659547 100644 --- a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp @@ -29,7 +29,7 @@ ErrorOr<void> DomainListModel::load() { // FIXME: This should be somewhat shared with Browser. auto file = TRY(Core::File::open(TRY(filter_list_file_path()), Core::File::OpenMode::Read)); - auto content_filter_list = TRY(Core::BufferedFile::create(move(file))); + auto content_filter_list = TRY(Core::InputBufferedFile::create(move(file))); auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); m_domain_list.clear_with_capacity(); diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp index 3dc21046f8..0f9a71a7ec 100644 --- a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp +++ b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp @@ -18,7 +18,7 @@ namespace FileManager { -FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation, NonnullOwnPtr<Core::BufferedFile> helper_pipe, int helper_pipe_fd) +FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation, NonnullOwnPtr<Core::InputBufferedFile> helper_pipe, int helper_pipe_fd) : m_operation(operation) , m_helper_pipe(move(helper_pipe)) { diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.h b/Userland/Applications/FileManager/FileOperationProgressWidget.h index d5aca5e42f..79f07d51db 100644 --- a/Userland/Applications/FileManager/FileOperationProgressWidget.h +++ b/Userland/Applications/FileManager/FileOperationProgressWidget.h @@ -21,7 +21,7 @@ public: private: // FIXME: The helper_pipe_fd parameter is only needed because we can't get the fd from a Core::Stream. - FileOperationProgressWidget(FileOperation, NonnullOwnPtr<Core::BufferedFile> helper_pipe, int helper_pipe_fd); + FileOperationProgressWidget(FileOperation, NonnullOwnPtr<Core::InputBufferedFile> helper_pipe, int helper_pipe_fd); void did_finish(); void did_error(StringView message); @@ -34,6 +34,6 @@ private: FileOperation m_operation; RefPtr<Core::Notifier> m_notifier; - OwnPtr<Core::BufferedFile> m_helper_pipe; + OwnPtr<Core::InputBufferedFile> m_helper_pipe; }; } diff --git a/Userland/Applications/FileManager/FileUtils.cpp b/Userland/Applications/FileManager/FileUtils.cpp index 17e19ace38..249d9cff61 100644 --- a/Userland/Applications/FileManager/FileUtils.cpp +++ b/Userland/Applications/FileManager/FileUtils.cpp @@ -99,7 +99,7 @@ ErrorOr<void> run_file_operation(FileOperation operation, Vector<DeprecatedStrin } auto pipe_input_file = TRY(Core::File::adopt_fd(pipe_fds[0], Core::File::OpenMode::Read)); - auto buffered_pipe = TRY(Core::BufferedFile::create(move(pipe_input_file))); + auto buffered_pipe = TRY(Core::InputBufferedFile::create(move(pipe_input_file))); (void)TRY(window->set_main_widget<FileOperationProgressWidget>(operation, move(buffered_pipe), pipe_fds[0])); window->resize(320, 190); diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp index d8454d2e5c..a6d8d5c351 100644 --- a/Userland/Applications/PixelPaint/PaletteWidget.cpp +++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp @@ -215,7 +215,7 @@ ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::File { Vector<Color> palette; Array<u8, PAGE_SIZE> buffer; - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); while (TRY(buffered_file->can_read_line())) { auto line = TRY(buffered_file->read_line(buffer)); diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp index fa06057f83..511f9af729 100644 --- a/Userland/Applications/Run/RunWindow.cpp +++ b/Userland/Applications/Run/RunWindow.cpp @@ -169,7 +169,7 @@ ErrorOr<void> RunWindow::load_history() { m_path_history.clear(); auto file = TRY(Core::File::open(history_file_path(), Core::File::OpenMode::Read)); - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); Array<u8, PAGE_SIZE> line_buffer; while (!buffered_file->is_eof()) { diff --git a/Userland/Applications/Welcome/WelcomeWidget.cpp b/Userland/Applications/Welcome/WelcomeWidget.cpp index 7241a5379f..cf1c3a8c7b 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.cpp +++ b/Userland/Applications/Welcome/WelcomeWidget.cpp @@ -95,7 +95,7 @@ ErrorOr<void> WelcomeWidget::open_and_parse_tips_file() { auto path = TRY(String::formatted("{}/tips.txt", Core::StandardPaths::documents_directory())); auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); Array<u8, PAGE_SIZE> buffer; while (TRY(buffered_file->can_read_line())) { diff --git a/Userland/DevTools/Profiler/SourceModel.cpp b/Userland/DevTools/Profiler/SourceModel.cpp index d23691a1e3..12fdd29a91 100644 --- a/Userland/DevTools/Profiler/SourceModel.cpp +++ b/Userland/DevTools/Profiler/SourceModel.cpp @@ -29,7 +29,7 @@ public: auto try_read_lines = [&]() -> ErrorOr<void> { auto unbuffered_file = TRY(Core::File::open(source_file_name, Core::File::OpenMode::Read)); - auto file = TRY(Core::BufferedFile::create(move(unbuffered_file))); + auto file = TRY(Core::InputBufferedFile::create(move(unbuffered_file))); Array<u8, 1024> buffer; while (!file->is_eof()) diff --git a/Userland/Games/MasterWord/WordGame.cpp b/Userland/Games/MasterWord/WordGame.cpp index 3192faae80..0e30a336ca 100644 --- a/Userland/Games/MasterWord/WordGame.cpp +++ b/Userland/Games/MasterWord/WordGame.cpp @@ -178,7 +178,7 @@ void WordGame::read_words() auto try_load_words = [&]() -> ErrorOr<void> { auto response = TRY(Core::File::open("/res/words.txt"sv, Core::File::OpenMode::Read)); - auto words_file = TRY(Core::BufferedFile::create(move(response))); + auto words_file = TRY(Core::InputBufferedFile::create(move(response))); Array<u8, 128> buffer; while (!words_file->is_eof()) { diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp index 4f23b7a709..851fda7137 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.cpp +++ b/Userland/Libraries/LibAudio/FlacLoader.cpp @@ -34,7 +34,7 @@ FlacLoaderPlugin::FlacLoaderPlugin(NonnullOwnPtr<SeekableStream> stream) Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::create(StringView path) { - auto stream = LOADER_TRY(Core::BufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read)))); + auto stream = LOADER_TRY(Core::InputBufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read)))); auto loader = make<FlacLoaderPlugin>(move(stream)); LOADER_TRY(loader->initialize()); diff --git a/Userland/Libraries/LibAudio/MP3Loader.cpp b/Userland/Libraries/LibAudio/MP3Loader.cpp index f3131ea2e7..b73dc28dc2 100644 --- a/Userland/Libraries/LibAudio/MP3Loader.cpp +++ b/Userland/Libraries/LibAudio/MP3Loader.cpp @@ -23,7 +23,7 @@ MP3LoaderPlugin::MP3LoaderPlugin(NonnullOwnPtr<SeekableStream> stream) Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::create(StringView path) { - auto stream = LOADER_TRY(Core::BufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read)))); + auto stream = LOADER_TRY(Core::InputBufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read)))); auto loader = make<MP3LoaderPlugin>(move(stream)); LOADER_TRY(loader->initialize()); diff --git a/Userland/Libraries/LibAudio/QOALoader.cpp b/Userland/Libraries/LibAudio/QOALoader.cpp index 68acf2eb96..bca3cb2601 100644 --- a/Userland/Libraries/LibAudio/QOALoader.cpp +++ b/Userland/Libraries/LibAudio/QOALoader.cpp @@ -26,7 +26,7 @@ QOALoaderPlugin::QOALoaderPlugin(NonnullOwnPtr<AK::SeekableStream> stream) Result<NonnullOwnPtr<QOALoaderPlugin>, LoaderError> QOALoaderPlugin::create(StringView path) { - auto stream = LOADER_TRY(Core::BufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read)))); + auto stream = LOADER_TRY(Core::InputBufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read)))); auto loader = make<QOALoaderPlugin>(move(stream)); LOADER_TRY(loader->initialize()); diff --git a/Userland/Libraries/LibAudio/WavLoader.cpp b/Userland/Libraries/LibAudio/WavLoader.cpp index 8abb2cb8fa..c4adf379b4 100644 --- a/Userland/Libraries/LibAudio/WavLoader.cpp +++ b/Userland/Libraries/LibAudio/WavLoader.cpp @@ -26,7 +26,7 @@ WavLoaderPlugin::WavLoaderPlugin(NonnullOwnPtr<SeekableStream> stream) Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::create(StringView path) { - auto stream = LOADER_TRY(Core::BufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read)))); + auto stream = LOADER_TRY(Core::InputBufferedFile::create(LOADER_TRY(Core::File::open(path, Core::File::OpenMode::Read)))); auto loader = make<WavLoaderPlugin>(move(stream)); LOADER_TRY(loader->initialize()); diff --git a/Userland/Libraries/LibChess/UCIEndpoint.h b/Userland/Libraries/LibChess/UCIEndpoint.h index 8c2104162b..b7b617547f 100644 --- a/Userland/Libraries/LibChess/UCIEndpoint.h +++ b/Userland/Libraries/LibChess/UCIEndpoint.h @@ -44,7 +44,7 @@ public: ErrorOr<void> set_in(NonnullOwnPtr<Core::File> in) { m_in_fd = in->fd(); - m_in = TRY(Core::BufferedFile::create(move(in))); + m_in = TRY(Core::InputBufferedFile::create(move(in))); set_in_notifier(); return {}; } @@ -62,7 +62,7 @@ private: ErrorOr<NonnullOwnPtr<Command>> read_command(StringView line) const; Optional<int> m_in_fd {}; - OwnPtr<Core::BufferedFile> m_in; + OwnPtr<Core::InputBufferedFile> m_in; OwnPtr<Core::File> m_out; RefPtr<Core::Notifier> m_in_notifier; }; diff --git a/Userland/Libraries/LibCompress/Gzip.cpp b/Userland/Libraries/LibCompress/Gzip.cpp index 5f00fbd683..3b5986f8ce 100644 --- a/Userland/Libraries/LibCompress/Gzip.cpp +++ b/Userland/Libraries/LibCompress/Gzip.cpp @@ -185,7 +185,7 @@ ErrorOr<ByteBuffer> GzipDecompressor::decompress_all(ReadonlyBytes bytes) ErrorOr<void> GzipDecompressor::decompress_file(StringView input_filename, NonnullOwnPtr<Stream> output_stream) { auto input_file = TRY(Core::File::open(input_filename, Core::File::OpenMode::Read)); - auto input_stream = TRY(Core::BufferedFile::create(move(input_file), 256 * KiB)); + auto input_stream = TRY(Core::InputBufferedFile::create(move(input_file), 256 * KiB)); auto gzip_stream = GzipDecompressor { move(input_stream) }; auto buffer = TRY(ByteBuffer::create_uninitialized(256 * KiB)); diff --git a/Userland/Libraries/LibCore/ConfigFile.cpp b/Userland/Libraries/LibCore/ConfigFile.cpp index a302fd9b46..4086710f8c 100644 --- a/Userland/Libraries/LibCore/ConfigFile.cpp +++ b/Userland/Libraries/LibCore/ConfigFile.cpp @@ -41,7 +41,7 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_system(DeprecatedString ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, AllowWriting allow_altering) { auto maybe_file = File::open(filename, allow_altering == AllowWriting::Yes ? File::OpenMode::ReadWrite : File::OpenMode::Read); - OwnPtr<BufferedFile> buffered_file; + OwnPtr<InputBufferedFile> buffered_file; if (maybe_file.is_error()) { // If we attempted to open a read-only file that does not exist, we ignore the error, making it appear // the same as if we had opened an empty file. This behavior is a little weird, but is required by @@ -49,7 +49,7 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& file if (!(allow_altering == AllowWriting::No && maybe_file.error().code() == ENOENT)) return maybe_file.release_error(); } else { - buffered_file = TRY(BufferedFile::create(maybe_file.release_value())); + buffered_file = TRY(InputBufferedFile::create(maybe_file.release_value())); } auto config_file = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ConfigFile(filename, move(buffered_file)))); @@ -65,14 +65,14 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& file ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, NonnullOwnPtr<Core::File> file) { - auto buffered_file = TRY(BufferedFile::create(move(file))); + auto buffered_file = TRY(InputBufferedFile::create(move(file))); auto config_file = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ConfigFile(filename, move(buffered_file)))); TRY(config_file->reparse()); return config_file; } -ConfigFile::ConfigFile(DeprecatedString const& filename, OwnPtr<BufferedFile> open_file) +ConfigFile::ConfigFile(DeprecatedString const& filename, OwnPtr<InputBufferedFile> open_file) : m_filename(filename) , m_file(move(open_file)) { diff --git a/Userland/Libraries/LibCore/ConfigFile.h b/Userland/Libraries/LibCore/ConfigFile.h index c003fc6e56..b8e4fc246b 100644 --- a/Userland/Libraries/LibCore/ConfigFile.h +++ b/Userland/Libraries/LibCore/ConfigFile.h @@ -79,12 +79,12 @@ public: DeprecatedString const& filename() const { return m_filename; } private: - ConfigFile(DeprecatedString const& filename, OwnPtr<BufferedFile> open_file); + ConfigFile(DeprecatedString const& filename, OwnPtr<InputBufferedFile> open_file); ErrorOr<void> reparse(); DeprecatedString m_filename; - OwnPtr<BufferedFile> m_file; + OwnPtr<InputBufferedFile> m_file; HashMap<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>> m_groups; bool m_dirty { false }; }; diff --git a/Userland/Libraries/LibCore/DeprecatedFile.h b/Userland/Libraries/LibCore/DeprecatedFile.h index ca5852dd49..cd871b7822 100644 --- a/Userland/Libraries/LibCore/DeprecatedFile.h +++ b/Userland/Libraries/LibCore/DeprecatedFile.h @@ -19,7 +19,7 @@ namespace Core { /// /// Use of Core::File for reading/writing data is deprecated. -/// Please use Core::File and Core::BufferedFile instead. +/// Please use Core::File and Core::InputBufferedFile instead. /// class DeprecatedFile final : public IODevice { C_OBJECT(DeprecatedFile) diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h index 22be6a5ec5..7a6728b9af 100644 --- a/Userland/Libraries/LibCore/File.h +++ b/Userland/Libraries/LibCore/File.h @@ -105,6 +105,6 @@ private: AK_ENUM_BITWISE_OPERATORS(File::OpenMode) -using BufferedFile = BufferedSeekable<File>; +using InputBufferedFile = InputBufferedSeekable<File>; } diff --git a/Userland/Libraries/LibSQL/Heap.cpp b/Userland/Libraries/LibSQL/Heap.cpp index 42ebe95418..8425e1d43c 100644 --- a/Userland/Libraries/LibSQL/Heap.cpp +++ b/Userland/Libraries/LibSQL/Heap.cpp @@ -48,7 +48,7 @@ ErrorOr<void> Heap::open() } auto file = TRY(Core::File::open(name(), Core::File::OpenMode::ReadWrite)); - m_file = TRY(Core::BufferedFile::create(move(file))); + m_file = TRY(Core::InputBufferedFile::create(move(file))); if (file_size > 0) { if (auto error_maybe = read_zero_block(); error_maybe.is_error()) { diff --git a/Userland/Libraries/LibSQL/Heap.h b/Userland/Libraries/LibSQL/Heap.h index 08de5a59b8..daf2363cb4 100644 --- a/Userland/Libraries/LibSQL/Heap.h +++ b/Userland/Libraries/LibSQL/Heap.h @@ -128,7 +128,7 @@ private: ErrorOr<void> initialize_zero_block(); ErrorOr<void> update_zero_block(); - OwnPtr<Core::BufferedFile> m_file; + OwnPtr<Core::InputBufferedFile> m_file; Block::Index m_highest_block_written { 0 }; Block::Index m_next_block { 1 }; Block::Index m_schemas_root { 0 }; diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index 30fdbcd552..47f56dbf51 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -1795,7 +1795,7 @@ ErrorOr<int> Shell::builtin_read(Main::Arguments arguments) split_by_any_of = TRY(const_cast<AST::Value&>(*split_by_variable).resolve_as_string(*this)); auto file = TRY(Core::File::standard_input()); - auto buffered_stream = TRY(Core::BufferedFile::create(move(file))); + auto buffered_stream = TRY(Core::InputBufferedFile::create(move(file))); StringBuilder builder; ByteBuffer buffer; diff --git a/Userland/Utilities/cmp.cpp b/Userland/Utilities/cmp.cpp index c0b107d409..28de834dda 100644 --- a/Userland/Utilities/cmp.cpp +++ b/Userland/Utilities/cmp.cpp @@ -10,10 +10,10 @@ #include <LibCore/System.h> #include <LibMain/Main.h> -static ErrorOr<NonnullOwnPtr<Core::BufferedFile>> open_file_or_stdin(StringView filename) +static ErrorOr<NonnullOwnPtr<Core::InputBufferedFile>> open_file_or_stdin(StringView filename) { auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read)); - return TRY(Core::BufferedFile::create(move(file))); + return TRY(Core::InputBufferedFile::create(move(file))); } ErrorOr<int> serenity_main(Main::Arguments arguments) diff --git a/Userland/Utilities/comm.cpp b/Userland/Utilities/comm.cpp index 31c23f23a8..8ca230a3a5 100644 --- a/Userland/Utilities/comm.cpp +++ b/Userland/Utilities/comm.cpp @@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return false; } - auto buffered_file_or_error = Core::BufferedFile::create(file_or_error.release_value()); + auto buffered_file_or_error = Core::InputBufferedFile::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 +83,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return true; }; - OwnPtr<Core::BufferedFile> file1; - OwnPtr<Core::BufferedFile> file2; + OwnPtr<Core::InputBufferedFile> file1; + OwnPtr<Core::InputBufferedFile> file2; if (!(open_file(file1_path, file1, 1) && open_file(file2_path, file2, 2))) return 1; diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index e819e23405..e73fddafc5 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -163,7 +163,7 @@ ErrorOr<int> serenity_main(Main::Arguments args) if (!pattern_file.is_empty()) { auto file = TRY(Core::File::open(pattern_file, Core::File::OpenMode::Read)); - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); Array<u8, PAGE_SIZE> buffer; while (!buffered_file->is_eof()) { auto next_pattern = TRY(buffered_file->read_line(buffer)); @@ -242,7 +242,7 @@ 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::File::open(filename, Core::File::OpenMode::Read)); - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::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/lzcat.cpp b/Userland/Utilities/lzcat.cpp index cc9d6ba936..320e814f9e 100644 --- a/Userland/Utilities/lzcat.cpp +++ b/Userland/Utilities/lzcat.cpp @@ -22,7 +22,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.parse(arguments); auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read)); - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); auto stream = TRY(Compress::LzmaDecompressor::create_from_container(move(buffered_file))); // Arbitrarily chosen buffer size. diff --git a/Userland/Utilities/mount.cpp b/Userland/Utilities/mount.cpp index e579a795a5..c5bc783531 100644 --- a/Userland/Utilities/mount.cpp +++ b/Userland/Utilities/mount.cpp @@ -113,7 +113,7 @@ static ErrorOr<void> mount_all() bool all_ok = true; auto process_fstab_entries = [&](StringView path) -> ErrorOr<void> { auto file_unbuffered = TRY(Core::File::open(path, Core::File::OpenMode::Read)); - auto file = TRY(Core::BufferedFile::create(move(file_unbuffered))); + auto file = TRY(Core::InputBufferedFile::create(move(file_unbuffered))); while (TRY(file->can_read_line())) { auto line = TRY(file->read_line(buffer)); diff --git a/Userland/Utilities/sed.cpp b/Userland/Utilities/sed.cpp index e6a4e72d01..9de2e59f62 100644 --- a/Userland/Utilities/sed.cpp +++ b/Userland/Utilities/sed.cpp @@ -613,7 +613,7 @@ enum class CycleDecision { class File { AK_MAKE_NONCOPYABLE(File); - File(LexicalPath input_file_path, NonnullOwnPtr<Core::BufferedFile>&& file, OwnPtr<Core::File>&& output, OwnPtr<FileSystem::TempFile>&& temp_file) + File(LexicalPath input_file_path, NonnullOwnPtr<Core::InputBufferedFile>&& file, OwnPtr<Core::File>&& output, OwnPtr<FileSystem::TempFile>&& temp_file) : m_input_file_path(move(input_file_path)) , m_file(move(file)) , m_output(move(output)) @@ -625,7 +625,7 @@ public: // Used for -i mode. static ErrorOr<File> create_with_output_file(LexicalPath input_path, NonnullOwnPtr<Core::File>&& file) { - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); auto temp_file = TRY(FileSystem::TempFile::create_temp_file()); // Open the file as read-write, since we need to later copy its contents to the original file. auto output_file = TRY(Core::File::open(temp_file->path(), Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate)); @@ -635,7 +635,7 @@ public: // Used for non -i mode. static ErrorOr<File> create(LexicalPath input_path, NonnullOwnPtr<Core::File>&& file) { - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); return File { move(input_path), move(buffered_file), nullptr, nullptr }; } @@ -650,7 +650,7 @@ public: // We hack standard output into `File` to avoid having two versions of `write_pattern_space`. return File { LexicalPath { "/proc/self/fd/1" }, - TRY(Core::BufferedFile::create(TRY(Core::File::standard_input()))), + TRY(Core::InputBufferedFile::create(TRY(Core::File::standard_input()))), TRY(Core::File::standard_output()), nullptr, }; @@ -697,12 +697,11 @@ public: private: LexicalPath m_input_file_path; - NonnullOwnPtr<Core::BufferedFile> m_file; + NonnullOwnPtr<Core::InputBufferedFile> m_file; // Only in use if we're editing in place. OwnPtr<Core::File> m_output; OwnPtr<FileSystem::TempFile> m_output_temp_file; - size_t m_line_number { 0 }; DeprecatedString m_current_line; constexpr static size_t MAX_SUPPORTED_LINE_SIZE = 4096; diff --git a/Userland/Utilities/sort.cpp b/Userland/Utilities/sort.cpp index 6894ba3aae..25413ef699 100644 --- a/Userland/Utilities/sort.cpp +++ b/Userland/Utilities/sort.cpp @@ -62,7 +62,7 @@ struct Options { static ErrorOr<void> load_file(Options options, StringView filename, Vector<Line>& lines, HashTable<Line>& seen) { - auto file = TRY(Core::BufferedFile::create( + auto file = TRY(Core::InputBufferedFile::create( TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read)))); // FIXME: Unlimited line length diff --git a/Userland/Utilities/sql.cpp b/Userland/Utilities/sql.cpp index 64567268c4..514d21e522 100644 --- a/Userland/Utilities/sql.cpp +++ b/Userland/Utilities/sql.cpp @@ -151,7 +151,7 @@ private: NonnullRefPtr<SQL::SQLClient> m_sql_client; SQL::ConnectionID m_connection_id { 0 }; Core::EventLoop& m_loop; - OwnPtr<Core::BufferedFile> m_input_file { nullptr }; + OwnPtr<Core::InputBufferedFile> m_input_file { nullptr }; bool m_quit_when_files_read { false }; Vector<DeprecatedString> m_input_file_chain {}; Array<u8, 4096> m_buffer {}; @@ -166,7 +166,7 @@ private: return {}; } - auto buffered_file_or_error = Core::BufferedFile::create(file_or_error.release_value()); + auto buffered_file_or_error = Core::InputBufferedFile::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/tar.cpp b/Userland/Utilities/tar.cpp index dcd3a4f4fc..9388578de5 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -74,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!directory.is_empty()) TRY(Core::System::chdir(directory)); - NonnullOwnPtr<Stream> input_stream = TRY(Core::BufferedFile::create(TRY(Core::File::open_file_or_standard_stream(archive_file, Core::File::OpenMode::Read)))); + NonnullOwnPtr<Stream> input_stream = TRY(Core::InputBufferedFile::create(TRY(Core::File::open_file_or_standard_stream(archive_file, Core::File::OpenMode::Read)))); if (gzip) input_stream = make<Compress::GzipDecompressor>(move(input_stream)); diff --git a/Userland/Utilities/uniq.cpp b/Userland/Utilities/uniq.cpp index f7609da2ca..e8f5abe82d 100644 --- a/Userland/Utilities/uniq.cpp +++ b/Userland/Utilities/uniq.cpp @@ -79,7 +79,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 0; } - auto infile = TRY(Core::BufferedFile::create(TRY(Core::File::open_file_or_standard_stream(inpath, Core::File::OpenMode::Read)))); + auto infile = TRY(Core::InputBufferedFile::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; diff --git a/Userland/Utilities/xzcat.cpp b/Userland/Utilities/xzcat.cpp index 19837711e8..4d9cca37b4 100644 --- a/Userland/Utilities/xzcat.cpp +++ b/Userland/Utilities/xzcat.cpp @@ -22,7 +22,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.parse(arguments); auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read)); - auto buffered_file = TRY(Core::BufferedFile::create(move(file))); + auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); auto stream = TRY(Compress::XzDecompressor::create(move(buffered_file))); // Arbitrarily chosen buffer size. |