mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
AK: Add the Input
word to input-only buffered streams
This concerns both `BufferedSeekable` and `BufferedFile`.
This commit is contained in:
parent
48b000a36c
commit
8c34959b53
Notes:
sideshowbarker
2024-07-17 01:46:00 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/8c34959b53 Pull-request: https://github.com/SerenityOS/serenity/pull/18590 Reviewed-by: https://github.com/timschumi ✅
50 changed files with 101 additions and 102 deletions
|
@ -264,17 +264,17 @@ private:
|
|||
// needed at the moment.
|
||||
|
||||
template<SeekableStreamLike T>
|
||||
class BufferedSeekable final : public SeekableStream {
|
||||
class InputBufferedSeekable final : public SeekableStream {
|
||||
friend BufferedHelper<T>;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<BufferedSeekable<T>>> create(NonnullOwnPtr<T> stream, size_t buffer_size = 16384)
|
||||
static ErrorOr<NonnullOwnPtr<InputBufferedSeekable<T>>> create(NonnullOwnPtr<T> stream, size_t buffer_size = 16384)
|
||||
{
|
||||
return BufferedHelper<T>::template create_buffered<BufferedSeekable>(move(stream), buffer_size);
|
||||
return BufferedHelper<T>::template create_buffered<InputBufferedSeekable>(move(stream), buffer_size);
|
||||
}
|
||||
|
||||
BufferedSeekable(BufferedSeekable&& other) = default;
|
||||
BufferedSeekable& operator=(BufferedSeekable&& other) = default;
|
||||
InputBufferedSeekable(InputBufferedSeekable&& other) = default;
|
||||
InputBufferedSeekable& operator=(InputBufferedSeekable&& other) = default;
|
||||
|
||||
virtual ErrorOr<Bytes> read_some(Bytes buffer) override { return m_helper.read(move(buffer)); }
|
||||
virtual ErrorOr<size_t> write_some(ReadonlyBytes buffer) override { return m_helper.stream().write_some(buffer); }
|
||||
|
@ -311,11 +311,11 @@ public:
|
|||
|
||||
size_t buffer_size() const { return m_helper.buffer_size(); }
|
||||
|
||||
virtual ~BufferedSeekable() override = default;
|
||||
virtual ~InputBufferedSeekable() override = default;
|
||||
|
||||
private:
|
||||
BufferedSeekable(NonnullOwnPtr<T> stream, CircularBuffer buffer)
|
||||
: m_helper(Badge<BufferedSeekable<T>> {}, move(stream), move(buffer))
|
||||
InputBufferedSeekable(NonnullOwnPtr<T> stream, CircularBuffer buffer)
|
||||
: m_helper(Badge<InputBufferedSeekable<T>> {}, move(stream), move(buffer))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -326,5 +326,5 @@ private:
|
|||
|
||||
#if USING_AK_GLOBALLY
|
||||
using AK::BufferedHelper;
|
||||
using AK::BufferedSeekable;
|
||||
using AK::InputBufferedSeekable;
|
||||
#endif
|
||||
|
|
|
@ -102,7 +102,7 @@ static ErrorOr<void> load_content_filters()
|
|||
return file_or_error.release_error();
|
||||
|
||||
auto file = file_or_error.release_value();
|
||||
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));
|
||||
|
||||
Vector<String> patterns;
|
||||
|
@ -131,7 +131,7 @@ static ErrorOr<void> load_autoplay_allowlist()
|
|||
return file_or_error.release_error();
|
||||
|
||||
auto file = file_or_error.release_value();
|
||||
auto allowlist = TRY(Core::BufferedFile::create(move(file)));
|
||||
auto allowlist = TRY(Core::InputBufferedFile::create(move(file)));
|
||||
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
||||
|
||||
Vector<String> origins;
|
||||
|
|
|
@ -32,7 +32,7 @@ static ErrorOr<void> handle_attached_debugger()
|
|||
// "nopass". See https://sourceware.org/bugzilla/show_bug.cgi?id=9425
|
||||
// for details.
|
||||
auto unbuffered_status_file = TRY(Core::File::open("/proc/self/status"sv, Core::File::OpenMode::Read));
|
||||
auto status_file = TRY(Core::BufferedFile::create(move(unbuffered_status_file)));
|
||||
auto status_file = TRY(Core::InputBufferedFile::create(move(unbuffered_status_file)));
|
||||
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
||||
while (TRY(status_file->can_read_line())) {
|
||||
auto line = TRY(status_file->read_line(buffer));
|
||||
|
|
|
@ -1699,7 +1699,7 @@ static DeprecatedString format_identifier(StringView owner, DeprecatedString ide
|
|||
return identifier;
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR& cldr)
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::InputBufferedFile& file, CLDR& cldr)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
@ -1727,7 +1727,7 @@ namespace Locale {
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr)
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::InputBufferedFile& file, CLDR& cldr)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
|
|
@ -1058,7 +1058,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString bcp47_path, DeprecatedSt
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR& cldr)
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::InputBufferedFile& file, CLDR& cldr)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
@ -1103,7 +1103,7 @@ namespace Locale {
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr)
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::InputBufferedFile& file, CLDR& cldr)
|
||||
{
|
||||
auto string_index_type = cldr.unique_strings.type_that_fits();
|
||||
|
||||
|
|
|
@ -743,7 +743,7 @@ static DeprecatedString format_identifier(StringView, DeprecatedString identifie
|
|||
return identifier.to_titlecase();
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR& cldr)
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::InputBufferedFile& file, CLDR& cldr)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
@ -766,7 +766,7 @@ namespace Locale {
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr)
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::InputBufferedFile& file, CLDR& cldr)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
|
|
@ -425,7 +425,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedStr
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR&)
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::InputBufferedFile& file, CLDR&)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
@ -446,7 +446,7 @@ namespace Locale {
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr)
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::InputBufferedFile& file, CLDR& cldr)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
|
|
@ -162,7 +162,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString dates_path, CLDR& cldr)
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR&)
|
||||
static ErrorOr<void> generate_unicode_locale_header(Core::InputBufferedFile& file, CLDR&)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
@ -183,7 +183,7 @@ namespace Locale {
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr)
|
||||
static ErrorOr<void> generate_unicode_locale_implementation(Core::InputBufferedFile& file, CLDR& cldr)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
|
|
@ -345,7 +345,7 @@ static ErrorOr<void> parse_time_zones(StringView time_zone_path, TimeZoneData& t
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_time_zone_coordinates(Core::BufferedFile& file, TimeZoneData& time_zone_data)
|
||||
static ErrorOr<void> parse_time_zone_coordinates(Core::InputBufferedFile& file, TimeZoneData& time_zone_data)
|
||||
{
|
||||
auto parse_coordinate = [](auto coordinate) {
|
||||
VERIFY(coordinate.substring_view(0, 1).is_one_of("+"sv, "-"sv));
|
||||
|
@ -448,7 +448,7 @@ static DeprecatedString format_identifier(StringView owner, DeprecatedString ide
|
|||
return identifier;
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_time_zone_data_header(Core::BufferedFile& file, TimeZoneData& time_zone_data)
|
||||
static ErrorOr<void> generate_time_zone_data_header(Core::InputBufferedFile& file, TimeZoneData& time_zone_data)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
@ -473,7 +473,7 @@ namespace TimeZone {
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_time_zone_data_implementation(Core::BufferedFile& file, TimeZoneData& time_zone_data)
|
||||
static ErrorOr<void> generate_time_zone_data_implementation(Core::InputBufferedFile& file, TimeZoneData& time_zone_data)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
|
|
@ -53,7 +53,7 @@ static void set_image_path_for_emoji(StringView emoji_resource_path, EmojiData&
|
|||
emoji.image_path = emoji_data.unique_strings.ensure(move(file));
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_emoji_test_data(Core::BufferedFile& file, EmojiData& emoji_data)
|
||||
static ErrorOr<void> parse_emoji_test_data(Core::InputBufferedFile& file, EmojiData& emoji_data)
|
||||
{
|
||||
static constexpr auto group_header = "# group: "sv;
|
||||
static constexpr auto subgroup_header = "# subgroup: "sv;
|
||||
|
@ -117,7 +117,7 @@ static ErrorOr<void> parse_emoji_test_data(Core::BufferedFile& file, EmojiData&
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_emoji_serenity_data(Core::BufferedFile& file, EmojiData& emoji_data)
|
||||
static ErrorOr<void> parse_emoji_serenity_data(Core::InputBufferedFile& file, EmojiData& emoji_data)
|
||||
{
|
||||
static constexpr auto code_point_header = "U+"sv;
|
||||
|
||||
|
@ -203,7 +203,7 @@ static ErrorOr<void> validate_emoji(StringView emoji_resource_path, EmojiData& e
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_emoji_data_header(Core::BufferedFile& file, EmojiData const&)
|
||||
static ErrorOr<void> generate_emoji_data_header(Core::InputBufferedFile& file, EmojiData const&)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
@ -212,7 +212,7 @@ static ErrorOr<void> generate_emoji_data_header(Core::BufferedFile& file, EmojiD
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_emoji_data_implementation(Core::BufferedFile& file, EmojiData const& emoji_data)
|
||||
static ErrorOr<void> generate_emoji_data_implementation(Core::InputBufferedFile& file, EmojiData const& emoji_data)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
@ -333,7 +333,7 @@ Optional<Emoji> find_emoji_for_code_points(ReadonlySpan<u32> code_points)
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_emoji_installation(Core::BufferedFile& file, EmojiData const& emoji_data)
|
||||
static ErrorOr<void> generate_emoji_installation(Core::InputBufferedFile& file, EmojiData const& emoji_data)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
|
|
@ -218,7 +218,7 @@ static CodePointRange parse_code_point_range(StringView list)
|
|||
return code_point_range;
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_special_casing(Core::BufferedFile& file, UnicodeData& unicode_data)
|
||||
static ErrorOr<void> parse_special_casing(Core::InputBufferedFile& file, UnicodeData& unicode_data)
|
||||
{
|
||||
Array<u8, 1024> buffer;
|
||||
|
||||
|
@ -289,7 +289,7 @@ static ErrorOr<void> parse_special_casing(Core::BufferedFile& file, UnicodeData&
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_case_folding(Core::BufferedFile& file, UnicodeData& unicode_data)
|
||||
static ErrorOr<void> parse_case_folding(Core::InputBufferedFile& file, UnicodeData& unicode_data)
|
||||
{
|
||||
Array<u8, 1024> buffer;
|
||||
|
||||
|
@ -337,7 +337,7 @@ static ErrorOr<void> parse_case_folding(Core::BufferedFile& file, UnicodeData& u
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_prop_list(Core::BufferedFile& file, PropList& prop_list, bool multi_value_property = false, bool sanitize_property = false)
|
||||
static ErrorOr<void> parse_prop_list(Core::InputBufferedFile& file, PropList& prop_list, bool multi_value_property = false, bool sanitize_property = false)
|
||||
{
|
||||
Array<u8, 1024> buffer;
|
||||
|
||||
|
@ -370,7 +370,7 @@ static ErrorOr<void> parse_prop_list(Core::BufferedFile& file, PropList& prop_li
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_alias_list(Core::BufferedFile& file, PropList const& prop_list, Vector<Alias>& prop_aliases)
|
||||
static ErrorOr<void> parse_alias_list(Core::InputBufferedFile& file, PropList const& prop_list, Vector<Alias>& prop_aliases)
|
||||
{
|
||||
DeprecatedString current_property;
|
||||
Array<u8, 1024> buffer;
|
||||
|
@ -416,7 +416,7 @@ static ErrorOr<void> parse_alias_list(Core::BufferedFile& file, PropList const&
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_name_aliases(Core::BufferedFile& file, UnicodeData& unicode_data)
|
||||
static ErrorOr<void> parse_name_aliases(Core::InputBufferedFile& file, UnicodeData& unicode_data)
|
||||
{
|
||||
Array<u8, 1024> buffer;
|
||||
|
||||
|
@ -447,7 +447,7 @@ static ErrorOr<void> parse_name_aliases(Core::BufferedFile& file, UnicodeData& u
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_value_alias_list(Core::BufferedFile& file, StringView desired_category, Vector<DeprecatedString> const& value_list, Vector<Alias>& prop_aliases, bool primary_value_is_first = true, bool sanitize_alias = false)
|
||||
static ErrorOr<void> parse_value_alias_list(Core::InputBufferedFile& file, StringView desired_category, Vector<DeprecatedString> const& value_list, Vector<Alias>& prop_aliases, bool primary_value_is_first = true, bool sanitize_alias = false)
|
||||
{
|
||||
TRY(file.seek(0, SeekMode::SetPosition));
|
||||
Array<u8, 1024> buffer;
|
||||
|
@ -493,7 +493,7 @@ static ErrorOr<void> parse_value_alias_list(Core::BufferedFile& file, StringView
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_normalization_props(Core::BufferedFile& file, UnicodeData& unicode_data)
|
||||
static ErrorOr<void> parse_normalization_props(Core::InputBufferedFile& file, UnicodeData& unicode_data)
|
||||
{
|
||||
Array<u8, 1024> buffer;
|
||||
|
||||
|
@ -627,7 +627,7 @@ static Optional<CodePointDecomposition> parse_decomposition_mapping(StringView s
|
|||
return mapping;
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_block_display_names(Core::BufferedFile& file, UnicodeData& unicode_data)
|
||||
static ErrorOr<void> parse_block_display_names(Core::InputBufferedFile& file, UnicodeData& unicode_data)
|
||||
{
|
||||
Array<u8, 1024> buffer;
|
||||
while (TRY(file.can_read_line())) {
|
||||
|
@ -650,7 +650,7 @@ static ErrorOr<void> parse_block_display_names(Core::BufferedFile& file, Unicode
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> parse_unicode_data(Core::BufferedFile& file, UnicodeData& unicode_data)
|
||||
static ErrorOr<void> parse_unicode_data(Core::InputBufferedFile& file, UnicodeData& unicode_data)
|
||||
{
|
||||
Optional<u32> code_point_range_start;
|
||||
|
||||
|
@ -755,7 +755,7 @@ static ErrorOr<void> parse_unicode_data(Core::BufferedFile& file, UnicodeData& u
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_data_header(Core::BufferedFile& file, UnicodeData& unicode_data)
|
||||
static ErrorOr<void> generate_unicode_data_header(Core::InputBufferedFile& file, UnicodeData& unicode_data)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
@ -870,7 +870,7 @@ ReadonlySpan<CaseFolding const*> case_folding_mapping(u32 code_point);
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_unicode_data_implementation(Core::BufferedFile& file, UnicodeData const& unicode_data)
|
||||
static ErrorOr<void> generate_unicode_data_implementation(Core::InputBufferedFile& file, UnicodeData const& unicode_data)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
|
|
@ -323,13 +323,13 @@ struct CanonicalLanguageID {
|
|||
Vector<size_t> variants {};
|
||||
};
|
||||
|
||||
inline ErrorOr<NonnullOwnPtr<Core::BufferedFile>> open_file(StringView path, Core::File::OpenMode mode)
|
||||
inline ErrorOr<NonnullOwnPtr<Core::InputBufferedFile>> open_file(StringView path, Core::File::OpenMode mode)
|
||||
{
|
||||
if (path.is_empty())
|
||||
return Error::from_string_literal("Provided path is empty, please provide all command line options");
|
||||
|
||||
auto file = TRY(Core::File::open(path, mode));
|
||||
return Core::BufferedFile::create(move(file));
|
||||
return Core::InputBufferedFile::create(move(file));
|
||||
}
|
||||
|
||||
inline ErrorOr<JsonValue> read_json_file(StringView path)
|
||||
|
|
|
@ -27,9 +27,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
bool had_errors = false;
|
||||
for (auto filename : arguments.strings.slice(1)) {
|
||||
|
||||
auto const open_file = [](StringView filename) -> ErrorOr<NonnullOwnPtr<Core::BufferedFile>> {
|
||||
auto const open_file = [](StringView filename) -> ErrorOr<NonnullOwnPtr<Core::InputBufferedFile>> {
|
||||
auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
|
||||
return Core::BufferedFile::create(move(file));
|
||||
return Core::InputBufferedFile::create(move(file));
|
||||
};
|
||||
|
||||
auto file_or_error = open_file(filename);
|
||||
|
|
|
@ -422,7 +422,7 @@ TEST_CASE(buffered_long_file_read)
|
|||
{
|
||||
auto maybe_file = Core::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::File::OpenMode::Read);
|
||||
EXPECT(!maybe_file.is_error());
|
||||
auto maybe_buffered_file = Core::BufferedFile::create(maybe_file.release_value());
|
||||
auto maybe_buffered_file = Core::InputBufferedFile::create(maybe_file.release_value());
|
||||
EXPECT(!maybe_buffered_file.is_error());
|
||||
auto file = maybe_buffered_file.release_value();
|
||||
|
||||
|
@ -444,7 +444,7 @@ TEST_CASE(buffered_small_file_read)
|
|||
{
|
||||
auto maybe_file = Core::File::open("/usr/Tests/LibCore/small.txt"sv, Core::File::OpenMode::Read);
|
||||
EXPECT(!maybe_file.is_error());
|
||||
auto maybe_buffered_file = Core::BufferedFile::create(maybe_file.release_value());
|
||||
auto maybe_buffered_file = Core::InputBufferedFile::create(maybe_file.release_value());
|
||||
EXPECT(!maybe_buffered_file.is_error());
|
||||
auto file = maybe_buffered_file.release_value();
|
||||
|
||||
|
@ -472,7 +472,7 @@ TEST_CASE(buffered_file_tell_and_seek)
|
|||
{
|
||||
// We choose a buffer size of 12 bytes to cover half of the input file.
|
||||
auto file = Core::File::open("/usr/Tests/LibCore/small.txt"sv, Core::File::OpenMode::Read).release_value();
|
||||
auto buffered_file = Core::BufferedFile::create(move(file), 12).release_value();
|
||||
auto buffered_file = Core::InputBufferedFile::create(move(file), 12).release_value();
|
||||
|
||||
// Initial state.
|
||||
{
|
||||
|
@ -562,7 +562,7 @@ TEST_CASE(buffered_file_without_newlines)
|
|||
EXPECT(!file_wo_newlines->write_until_depleted(new_newlines_message.bytes()).is_error());
|
||||
file_wo_newlines->close();
|
||||
|
||||
auto ro_file = Core::BufferedFile::create(Core::File::open(filename, Core::File::OpenMode::Read).release_value(), new_newlines_message.length() + 1).release_value();
|
||||
auto ro_file = Core::InputBufferedFile::create(Core::File::open(filename, Core::File::OpenMode::Read).release_value(), new_newlines_message.length() + 1).release_value();
|
||||
|
||||
auto maybe_can_read_line = ro_file->can_read_line();
|
||||
EXPECT(!maybe_can_read_line.is_error());
|
||||
|
|
|
@ -695,7 +695,7 @@ int main(int argc, char** argv)
|
|||
return exit_setup_input_failure;
|
||||
|
||||
Array<u8, 1024> input_buffer {};
|
||||
auto buffered_standard_input_or_error = Core::BufferedFile::create(standard_input_or_error.release_value());
|
||||
auto buffered_standard_input_or_error = Core::InputBufferedFile::create(standard_input_or_error.release_value());
|
||||
if (buffered_standard_input_or_error.is_error())
|
||||
return exit_setup_input_failure;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -105,6 +105,6 @@ private:
|
|||
|
||||
AK_ENUM_BITWISE_OPERATORS(File::OpenMode)
|
||||
|
||||
using BufferedFile = BufferedSeekable<File>;
|
||||
using InputBufferedFile = InputBufferedSeekable<File>;
|
||||
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {};
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue