mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:32:43 +00:00 
			
		
		
		
	LibCore: Move Stream-based file into the Core namespace
				
					
				
			This commit is contained in:
		
							parent
							
								
									a96339b72b
								
							
						
					
					
						commit
						606a3982f3
					
				
					 218 changed files with 748 additions and 643 deletions
				
			
		|  | @ -111,13 +111,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
| 
 | ||||
| static ErrorOr<void> load_content_filters() | ||||
| { | ||||
|     auto file_or_error = Core::Stream::File::open(DeprecatedString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::Stream::OpenMode::Read); | ||||
|     auto file_or_error = Core::File::open(DeprecatedString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); | ||||
|     if (file_or_error.is_error()) | ||||
|         file_or_error = Core::Stream::File::open(DeprecatedString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::Stream::OpenMode::Read); | ||||
|         file_or_error = Core::File::open(DeprecatedString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); | ||||
|     if (file_or_error.is_error()) | ||||
|         return file_or_error.release_error(); | ||||
|     auto file = file_or_error.release_value(); | ||||
|     auto ad_filter_list = TRY(Core::Stream::BufferedFile::create(move(file))); | ||||
|     auto ad_filter_list = TRY(Core::BufferedFile::create(move(file))); | ||||
|     auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); | ||||
|     while (TRY(ad_filter_list->can_read_line())) { | ||||
|         auto line = TRY(ad_filter_list->read_line(buffer)); | ||||
|  |  | |||
|  | @ -1006,7 +1006,7 @@ Gfx::IntRect WebContentView::notify_server_did_request_fullscreen_window() | |||
| 
 | ||||
| void WebContentView::notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32 request_id) | ||||
| { | ||||
|     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()) | ||||
|         client().async_handle_file_return(file.error().code(), {}, request_id); | ||||
|     else | ||||
|  |  | |||
|  | @ -31,8 +31,8 @@ static ErrorOr<void> handle_attached_debugger() | |||
|     // incorrectly forwards the signal to us even when it's set to
 | ||||
|     // "nopass". See https://sourceware.org/bugzilla/show_bug.cgi?id=9425
 | ||||
|     // for details.
 | ||||
|     auto unbuffered_status_file = TRY(Core::Stream::File::open("/proc/self/status"sv, Core::Stream::OpenMode::Read)); | ||||
|     auto status_file = TRY(Core::Stream::BufferedFile::create(move(unbuffered_status_file))); | ||||
|     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 buffer = TRY(ByteBuffer::create_uninitialized(4096)); | ||||
|     while (TRY(status_file->can_read_line())) { | ||||
|         auto line = TRY(status_file->read_line(buffer)); | ||||
|  |  | |||
|  | @ -10,6 +10,7 @@ | |||
| #include <AK/HashMap.h> | ||||
| #include <AK/SourceGenerator.h> | ||||
| #include <AK/StringBuilder.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibMain/Main.h> | ||||
| #include <ctype.h> | ||||
|  | @ -69,7 +70,7 @@ static bool is_primitive_type(DeprecatedString const& type) | |||
| static bool is_simple_type(DeprecatedString const& type) | ||||
| { | ||||
|     // Small types that it makes sense just to pass by value.
 | ||||
|     return type.is_one_of("Gfx::Color", "Gfx::IntPoint", "Gfx::FloatPoint", "Gfx::IntSize", "Gfx::FloatSize", "Core::Stream::OpenMode"); | ||||
|     return type.is_one_of("Gfx::Color", "Gfx::IntPoint", "Gfx::FloatPoint", "Gfx::IntSize", "Gfx::FloatSize", "Core::File::OpenMode"); | ||||
| } | ||||
| 
 | ||||
| static bool is_primitive_or_simple_type(DeprecatedString const& type) | ||||
|  | @ -796,7 +797,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|         return 1; | ||||
|     } | ||||
| 
 | ||||
|     auto file = TRY(Core::Stream::File::open(arguments.strings[1], Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open(arguments.strings[1], Core::File::OpenMode::Read)); | ||||
| 
 | ||||
|     auto file_contents = TRY(file->read_until_eof()); | ||||
| 
 | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
| 
 | ||||
| #include <AK/SourceGenerator.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| 
 | ||||
| enum class PnpIdColumns { | ||||
|  | @ -116,7 +117,7 @@ static ErrorOr<ApprovalDate> parse_approval_date(StringView const& str) | |||
|     return ApprovalDate { .year = year.value(), .month = month.value(), .day = day.value() }; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<HashMap<DeprecatedString, PnpIdData>> parse_pnp_ids_database(Core::Stream::File& pnp_ids_file) | ||||
| static ErrorOr<HashMap<DeprecatedString, PnpIdData>> parse_pnp_ids_database(Core::File& pnp_ids_file) | ||||
| { | ||||
|     auto pnp_ids_file_bytes = TRY(pnp_ids_file.read_until_eof()); | ||||
|     StringView pnp_ids_file_contents(pnp_ids_file_bytes); | ||||
|  | @ -181,7 +182,7 @@ static ErrorOr<HashMap<DeprecatedString, PnpIdData>> parse_pnp_ids_database(Core | |||
|     return pnp_id_data; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_header(Core::Stream::File& file, HashMap<DeprecatedString, PnpIdData> const& pnp_ids) | ||||
| static ErrorOr<void> generate_header(Core::File& file, HashMap<DeprecatedString, PnpIdData> const& pnp_ids) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -215,7 +216,7 @@ namespace PnpIDs { | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_source(Core::Stream::File& file, HashMap<DeprecatedString, PnpIdData> const& pnp_ids) | ||||
| static ErrorOr<void> generate_source(Core::File& file, HashMap<DeprecatedString, PnpIdData> const& pnp_ids) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -281,17 +282,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_option(pnp_ids_file_path, "Path to the input PNP ID database file", "pnp-ids-file", 'p', "pnp-ids-file"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     auto open_file = [&](StringView path, Core::Stream::OpenMode mode = Core::Stream::OpenMode::Read) -> ErrorOr<NonnullOwnPtr<Core::Stream::File>> { | ||||
|     auto open_file = [&](StringView path, Core::File::OpenMode mode = Core::File::OpenMode::Read) -> ErrorOr<NonnullOwnPtr<Core::File>> { | ||||
|         if (path.is_empty()) { | ||||
|             args_parser.print_usage(stderr, arguments.argv[0]); | ||||
|             return Error::from_string_literal("Must provide all command line options"); | ||||
|         } | ||||
| 
 | ||||
|         return Core::Stream::File::open(path, mode); | ||||
|         return Core::File::open(path, mode); | ||||
|     }; | ||||
| 
 | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::Stream::OpenMode::ReadWrite)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::Stream::OpenMode::ReadWrite)); | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::File::OpenMode::ReadWrite)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::File::OpenMode::ReadWrite)); | ||||
|     auto pnp_ids_file = TRY(open_file(pnp_ids_file_path)); | ||||
| 
 | ||||
|     auto pnp_id_map = TRY(parse_pnp_ids_database(*pnp_ids_file)); | ||||
|  |  | |||
|  | @ -14,6 +14,7 @@ | |||
| #include <AK/StringView.h> | ||||
| #include <AK/Vector.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibMain/Main.h> | ||||
| 
 | ||||
|  | @ -355,7 +356,7 @@ Vector<FunctionDefinition> create_function_definitions(DeprecatedString function | |||
|     return functions; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonObject& api_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_header_file(JsonObject& api_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -409,7 +410,7 @@ ErrorOr<void> generate_header_file(JsonObject& api_data, Core::Stream::File& fil | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& api_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& api_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -535,7 +536,7 @@ ErrorOr<void> generate_implementation_file(JsonObject& api_data, Core::Stream::F | |||
| 
 | ||||
| ErrorOr<JsonValue> read_entire_file_as_json(StringView filename) | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read)); | ||||
|     auto json_size = TRY(file->size()); | ||||
|     auto json_data = TRY(ByteBuffer::create_uninitialized(json_size)); | ||||
|     TRY(file->read_entire_buffer(json_data.bytes())); | ||||
|  | @ -558,8 +559,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     VERIFY(json.is_object()); | ||||
|     auto api_data = json.as_object(); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(Core::Stream::File::open(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::Stream::File::open(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     TRY(generate_header_file(api_data, *generated_header_file)); | ||||
|     TRY(generate_implementation_file(api_data, *generated_implementation_file)); | ||||
|  |  | |||
|  | @ -1701,7 +1701,7 @@ static DeprecatedString format_identifier(StringView owner, DeprecatedString ide | |||
|     return identifier; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::Stream::BufferedFile& file, CLDR& cldr) | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR& cldr) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -1729,7 +1729,7 @@ namespace Locale { | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::Stream::BufferedFile& file, CLDR& cldr) | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -2416,8 +2416,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_option(dates_path, "Path to cldr-dates directory", "dates-path", 'd', "dates-path"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     CLDR cldr; | ||||
|     TRY(parse_all_locales(core_path, dates_path, cldr)); | ||||
|  |  | |||
|  | @ -1007,7 +1007,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString bcp47_path, DeprecatedSt | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::Stream::BufferedFile& file, CLDR& cldr) | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR& cldr) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -1052,7 +1052,7 @@ namespace Locale { | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::Stream::BufferedFile& file, CLDR& cldr) | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr) | ||||
| { | ||||
|     auto string_index_type = cldr.unique_strings.type_that_fits(); | ||||
| 
 | ||||
|  | @ -1774,8 +1774,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_option(dates_path, "Path to cldr-dates directory", "dates-path", 'd', "dates-path"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     CLDR cldr; | ||||
|     TRY(parse_all_locales(bcp47_path, core_path, locale_names_path, misc_path, numbers_path, dates_path, cldr)); | ||||
|  |  | |||
|  | @ -745,7 +745,7 @@ static DeprecatedString format_identifier(StringView, DeprecatedString identifie | |||
|     return identifier.to_titlecase(); | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::Stream::BufferedFile& file, CLDR& cldr) | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR& cldr) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -768,7 +768,7 @@ namespace Locale { | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::Stream::BufferedFile& file, CLDR& cldr) | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -1128,8 +1128,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_option(units_path, "Path to cldr-units directory", "units-path", 'u', "units-path"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     CLDR cldr; | ||||
|     TRY(parse_all_locales(core_path, numbers_path, units_path, cldr)); | ||||
|  |  | |||
|  | @ -426,7 +426,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedStr | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::Stream::BufferedFile& file, CLDR&) | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR&) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -447,7 +447,7 @@ namespace Locale { | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::Stream::BufferedFile& file, CLDR& cldr) | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -673,8 +673,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_option(locale_names_path, "Path to cldr-localenames directory", "locale-names-path", 'l', "locale-names-path"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     CLDR cldr; | ||||
|     TRY(parse_all_locales(core_path, locale_names_path, cldr)); | ||||
|  |  | |||
|  | @ -164,7 +164,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString dates_path, CLDR& cldr) | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::Stream::BufferedFile& file, CLDR&) | ||||
| static ErrorOr<void> generate_unicode_locale_header(Core::BufferedFile& file, CLDR&) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -185,7 +185,7 @@ namespace Locale { | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::Stream::BufferedFile& file, CLDR& cldr) | ||||
| static ErrorOr<void> generate_unicode_locale_implementation(Core::BufferedFile& file, CLDR& cldr) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -293,8 +293,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_option(dates_path, "Path to cldr-dates directory", "dates-path", 'd', "dates-path"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     CLDR cldr; | ||||
|     TRY(parse_all_locales(dates_path, cldr)); | ||||
|  |  | |||
|  | @ -317,7 +317,7 @@ static void parse_rule(StringView rule_line, TimeZoneData& time_zone_data) | |||
| static ErrorOr<void> parse_time_zones(StringView time_zone_path, TimeZoneData& time_zone_data) | ||||
| { | ||||
|     // For reference, the man page for `zic` has the best documentation of the TZDB file format.
 | ||||
|     auto file = TRY(open_file(time_zone_path, Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(open_file(time_zone_path, Core::File::OpenMode::Read)); | ||||
|     Array<u8, 1024> buffer {}; | ||||
| 
 | ||||
|     Vector<TimeZoneOffset>* last_parsed_zone = nullptr; | ||||
|  | @ -346,7 +346,7 @@ static ErrorOr<void> parse_time_zones(StringView time_zone_path, TimeZoneData& t | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_time_zone_coordinates(Core::Stream::BufferedFile& file, TimeZoneData& time_zone_data) | ||||
| static ErrorOr<void> parse_time_zone_coordinates(Core::BufferedFile& 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::Stream::BufferedFile& file, TimeZoneData& time_zone_data) | ||||
| static ErrorOr<void> generate_time_zone_data_header(Core::BufferedFile& 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::Stream::BufferedFile& file, TimeZoneData& time_zone_data) | ||||
| static ErrorOr<void> generate_time_zone_data_implementation(Core::BufferedFile& file, TimeZoneData& time_zone_data) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -819,9 +819,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_positional_argument(time_zone_paths, "Paths to the time zone database files", "time-zone-paths"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto time_zone_coordinates_file = TRY(open_file(time_zone_coordinates_path, Core::Stream::OpenMode::Read)); | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
|     auto time_zone_coordinates_file = TRY(open_file(time_zone_coordinates_path, Core::File::OpenMode::Read)); | ||||
| 
 | ||||
|     TimeZoneData time_zone_data {}; | ||||
|     for (auto time_zone_path : time_zone_paths) | ||||
|  |  | |||
|  | @ -50,7 +50,7 @@ static void set_image_path_for_emoji(StringView emoji_resource_path, Emoji& emoj | |||
|         emoji.image_path = move(path); | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_emoji_test_data(Core::Stream::BufferedFile& file, EmojiData& emoji_data) | ||||
| static ErrorOr<void> parse_emoji_test_data(Core::BufferedFile& file, EmojiData& emoji_data) | ||||
| { | ||||
|     static constexpr auto group_header = "# group: "sv; | ||||
|     static constexpr auto subgroup_header = "# subgroup: "sv; | ||||
|  | @ -114,7 +114,7 @@ static ErrorOr<void> parse_emoji_test_data(Core::Stream::BufferedFile& file, Emo | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_emoji_serenity_data(Core::Stream::BufferedFile& file, EmojiData& emoji_data) | ||||
| static ErrorOr<void> parse_emoji_serenity_data(Core::BufferedFile& file, EmojiData& emoji_data) | ||||
| { | ||||
|     static constexpr auto code_point_header = "U+"sv; | ||||
| 
 | ||||
|  | @ -164,7 +164,7 @@ static ErrorOr<void> parse_emoji_serenity_data(Core::Stream::BufferedFile& file, | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_emoji_data_header(Core::Stream::BufferedFile& file, EmojiData const&) | ||||
| static ErrorOr<void> generate_emoji_data_header(Core::BufferedFile& file, EmojiData const&) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -173,7 +173,7 @@ static ErrorOr<void> generate_emoji_data_header(Core::Stream::BufferedFile& file | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_emoji_data_implementation(Core::Stream::BufferedFile& file, EmojiData const& emoji_data) | ||||
| static ErrorOr<void> generate_emoji_data_implementation(Core::BufferedFile& file, EmojiData const& emoji_data) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -276,7 +276,7 @@ Optional<Emoji> find_emoji_for_code_points(ReadonlySpan<u32> code_points) | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_emoji_installation(Core::Stream::BufferedFile& file, EmojiData const& emoji_data) | ||||
| static ErrorOr<void> generate_emoji_installation(Core::BufferedFile& file, EmojiData const& emoji_data) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -339,14 +339,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_option(emoji_resource_path, "Path to the /res/emoji directory", "emoji-resource-path", 'r', "emoji-resource-path"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     auto emoji_test_file = TRY(open_file(emoji_test_path, Core::Stream::OpenMode::Read)); | ||||
|     auto emoji_test_file = TRY(open_file(emoji_test_path, Core::File::OpenMode::Read)); | ||||
|     VERIFY(!emoji_resource_path.is_empty() && Core::DeprecatedFile::exists(emoji_resource_path)); | ||||
| 
 | ||||
|     EmojiData emoji_data {}; | ||||
|     TRY(parse_emoji_test_data(*emoji_test_file, emoji_data)); | ||||
| 
 | ||||
|     if (!emoji_serenity_path.is_empty()) { | ||||
|         auto emoji_serenity_file = TRY(open_file(emoji_serenity_path, Core::Stream::OpenMode::Read)); | ||||
|         auto emoji_serenity_file = TRY(open_file(emoji_serenity_path, Core::File::OpenMode::Read)); | ||||
|         TRY(parse_emoji_serenity_data(*emoji_serenity_file, emoji_data)); | ||||
|     } | ||||
| 
 | ||||
|  | @ -357,11 +357,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     } | ||||
| 
 | ||||
|     if (!generated_header_path.is_empty()) { | ||||
|         auto generated_header_file = TRY(open_file(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|         auto generated_header_file = TRY(open_file(generated_header_path, Core::File::OpenMode::Write)); | ||||
|         TRY(generate_emoji_data_header(*generated_header_file, emoji_data)); | ||||
|     } | ||||
|     if (!generated_implementation_path.is_empty()) { | ||||
|         auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|         auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
|         TRY(generate_emoji_data_implementation(*generated_implementation_file, emoji_data)); | ||||
|     } | ||||
| 
 | ||||
|  | @ -371,7 +371,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|         for (auto& emoji : emoji_data.emojis) | ||||
|             set_image_path_for_emoji(emoji_resource_path, emoji); | ||||
| 
 | ||||
|         auto generated_installation_file = TRY(open_file(generated_installation_path, Core::Stream::OpenMode::Write)); | ||||
|         auto generated_installation_file = TRY(open_file(generated_installation_path, Core::File::OpenMode::Write)); | ||||
|         TRY(generate_emoji_installation(*generated_installation_file, emoji_data)); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -219,7 +219,7 @@ static CodePointRange parse_code_point_range(StringView list) | |||
|     return code_point_range; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_special_casing(Core::Stream::BufferedFile& file, UnicodeData& unicode_data) | ||||
| static ErrorOr<void> parse_special_casing(Core::BufferedFile& file, UnicodeData& unicode_data) | ||||
| { | ||||
|     Array<u8, 1024> buffer; | ||||
| 
 | ||||
|  | @ -290,7 +290,7 @@ static ErrorOr<void> parse_special_casing(Core::Stream::BufferedFile& file, Unic | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_case_folding(Core::Stream::BufferedFile& file, UnicodeData& unicode_data) | ||||
| static ErrorOr<void> parse_case_folding(Core::BufferedFile& file, UnicodeData& unicode_data) | ||||
| { | ||||
|     Array<u8, 1024> buffer; | ||||
| 
 | ||||
|  | @ -338,7 +338,7 @@ static ErrorOr<void> parse_case_folding(Core::Stream::BufferedFile& file, Unicod | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_prop_list(Core::Stream::BufferedFile& file, PropList& prop_list, bool multi_value_property = false, bool sanitize_property = false) | ||||
| static ErrorOr<void> parse_prop_list(Core::BufferedFile& file, PropList& prop_list, bool multi_value_property = false, bool sanitize_property = false) | ||||
| { | ||||
|     Array<u8, 1024> buffer; | ||||
| 
 | ||||
|  | @ -371,7 +371,7 @@ static ErrorOr<void> parse_prop_list(Core::Stream::BufferedFile& file, PropList& | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_alias_list(Core::Stream::BufferedFile& file, PropList const& prop_list, Vector<Alias>& prop_aliases) | ||||
| static ErrorOr<void> parse_alias_list(Core::BufferedFile& file, PropList const& prop_list, Vector<Alias>& prop_aliases) | ||||
| { | ||||
|     DeprecatedString current_property; | ||||
|     Array<u8, 1024> buffer; | ||||
|  | @ -417,7 +417,7 @@ static ErrorOr<void> parse_alias_list(Core::Stream::BufferedFile& file, PropList | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_name_aliases(Core::Stream::BufferedFile& file, UnicodeData& unicode_data) | ||||
| static ErrorOr<void> parse_name_aliases(Core::BufferedFile& file, UnicodeData& unicode_data) | ||||
| { | ||||
|     Array<u8, 1024> buffer; | ||||
| 
 | ||||
|  | @ -448,7 +448,7 @@ static ErrorOr<void> parse_name_aliases(Core::Stream::BufferedFile& file, Unicod | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_value_alias_list(Core::Stream::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::BufferedFile& 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; | ||||
|  | @ -494,7 +494,7 @@ static ErrorOr<void> parse_value_alias_list(Core::Stream::BufferedFile& file, St | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_normalization_props(Core::Stream::BufferedFile& file, UnicodeData& unicode_data) | ||||
| static ErrorOr<void> parse_normalization_props(Core::BufferedFile& file, UnicodeData& unicode_data) | ||||
| { | ||||
|     Array<u8, 1024> buffer; | ||||
| 
 | ||||
|  | @ -628,7 +628,7 @@ static Optional<CodePointDecomposition> parse_decomposition_mapping(StringView s | |||
|     return mapping; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_block_display_names(Core::Stream::BufferedFile& file, UnicodeData& unicode_data) | ||||
| static ErrorOr<void> parse_block_display_names(Core::BufferedFile& file, UnicodeData& unicode_data) | ||||
| { | ||||
|     Array<u8, 1024> buffer; | ||||
|     while (TRY(file.can_read_line())) { | ||||
|  | @ -651,7 +651,7 @@ static ErrorOr<void> parse_block_display_names(Core::Stream::BufferedFile& file, | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> parse_unicode_data(Core::Stream::BufferedFile& file, UnicodeData& unicode_data) | ||||
| static ErrorOr<void> parse_unicode_data(Core::BufferedFile& file, UnicodeData& unicode_data) | ||||
| { | ||||
|     Optional<u32> code_point_range_start; | ||||
| 
 | ||||
|  | @ -756,7 +756,7 @@ static ErrorOr<void> parse_unicode_data(Core::Stream::BufferedFile& file, Unicod | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_data_header(Core::Stream::BufferedFile& file, UnicodeData& unicode_data) | ||||
| static ErrorOr<void> generate_unicode_data_header(Core::BufferedFile& file, UnicodeData& unicode_data) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -871,7 +871,7 @@ ReadonlySpan<CaseFolding const*> case_folding_mapping(u32 code_point); | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| static ErrorOr<void> generate_unicode_data_implementation(Core::Stream::BufferedFile& file, UnicodeData const& unicode_data) | ||||
| static ErrorOr<void> generate_unicode_data_implementation(Core::BufferedFile& file, UnicodeData const& unicode_data) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -1530,26 +1530,26 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_option(sentence_break_path, "Path to SentenceBreakProperty.txt file", "sentence-break-path", 'i', "sentence-break-path"); | ||||
|     args_parser.parse(arguments); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto unicode_data_file = TRY(open_file(unicode_data_path, Core::Stream::OpenMode::Read)); | ||||
|     auto derived_general_category_file = TRY(open_file(derived_general_category_path, Core::Stream::OpenMode::Read)); | ||||
|     auto special_casing_file = TRY(open_file(special_casing_path, Core::Stream::OpenMode::Read)); | ||||
|     auto case_folding_file = TRY(open_file(case_folding_path, Core::Stream::OpenMode::Read)); | ||||
|     auto prop_list_file = TRY(open_file(prop_list_path, Core::Stream::OpenMode::Read)); | ||||
|     auto derived_core_prop_file = TRY(open_file(derived_core_prop_path, Core::Stream::OpenMode::Read)); | ||||
|     auto derived_binary_prop_file = TRY(open_file(derived_binary_prop_path, Core::Stream::OpenMode::Read)); | ||||
|     auto prop_alias_file = TRY(open_file(prop_alias_path, Core::Stream::OpenMode::Read)); | ||||
|     auto prop_value_alias_file = TRY(open_file(prop_value_alias_path, Core::Stream::OpenMode::Read)); | ||||
|     auto name_alias_file = TRY(open_file(name_alias_path, Core::Stream::OpenMode::Read)); | ||||
|     auto scripts_file = TRY(open_file(scripts_path, Core::Stream::OpenMode::Read)); | ||||
|     auto script_extensions_file = TRY(open_file(script_extensions_path, Core::Stream::OpenMode::Read)); | ||||
|     auto blocks_file = TRY(open_file(blocks_path, Core::Stream::OpenMode::Read)); | ||||
|     auto emoji_data_file = TRY(open_file(emoji_data_path, Core::Stream::OpenMode::Read)); | ||||
|     auto normalization_file = TRY(open_file(normalization_path, Core::Stream::OpenMode::Read)); | ||||
|     auto grapheme_break_file = TRY(open_file(grapheme_break_path, Core::Stream::OpenMode::Read)); | ||||
|     auto word_break_file = TRY(open_file(word_break_path, Core::Stream::OpenMode::Read)); | ||||
|     auto sentence_break_file = TRY(open_file(sentence_break_path, Core::Stream::OpenMode::Read)); | ||||
|     auto generated_header_file = TRY(open_file(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(open_file(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
|     auto unicode_data_file = TRY(open_file(unicode_data_path, Core::File::OpenMode::Read)); | ||||
|     auto derived_general_category_file = TRY(open_file(derived_general_category_path, Core::File::OpenMode::Read)); | ||||
|     auto special_casing_file = TRY(open_file(special_casing_path, Core::File::OpenMode::Read)); | ||||
|     auto case_folding_file = TRY(open_file(case_folding_path, Core::File::OpenMode::Read)); | ||||
|     auto prop_list_file = TRY(open_file(prop_list_path, Core::File::OpenMode::Read)); | ||||
|     auto derived_core_prop_file = TRY(open_file(derived_core_prop_path, Core::File::OpenMode::Read)); | ||||
|     auto derived_binary_prop_file = TRY(open_file(derived_binary_prop_path, Core::File::OpenMode::Read)); | ||||
|     auto prop_alias_file = TRY(open_file(prop_alias_path, Core::File::OpenMode::Read)); | ||||
|     auto prop_value_alias_file = TRY(open_file(prop_value_alias_path, Core::File::OpenMode::Read)); | ||||
|     auto name_alias_file = TRY(open_file(name_alias_path, Core::File::OpenMode::Read)); | ||||
|     auto scripts_file = TRY(open_file(scripts_path, Core::File::OpenMode::Read)); | ||||
|     auto script_extensions_file = TRY(open_file(script_extensions_path, Core::File::OpenMode::Read)); | ||||
|     auto blocks_file = TRY(open_file(blocks_path, Core::File::OpenMode::Read)); | ||||
|     auto emoji_data_file = TRY(open_file(emoji_data_path, Core::File::OpenMode::Read)); | ||||
|     auto normalization_file = TRY(open_file(normalization_path, Core::File::OpenMode::Read)); | ||||
|     auto grapheme_break_file = TRY(open_file(grapheme_break_path, Core::File::OpenMode::Read)); | ||||
|     auto word_break_file = TRY(open_file(word_break_path, Core::File::OpenMode::Read)); | ||||
|     auto sentence_break_file = TRY(open_file(sentence_break_path, Core::File::OpenMode::Read)); | ||||
| 
 | ||||
|     UnicodeData unicode_data {}; | ||||
|     TRY(parse_special_casing(*special_casing_file, unicode_data)); | ||||
|  |  | |||
|  | @ -20,6 +20,7 @@ | |||
| #include <AK/Traits.h> | ||||
| #include <AK/Vector.h> | ||||
| #include <LibCore/DirIterator.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibLocale/Locale.h> | ||||
| 
 | ||||
|  | @ -323,18 +324,18 @@ struct CanonicalLanguageID { | |||
|     Vector<size_t> variants {}; | ||||
| }; | ||||
| 
 | ||||
| inline ErrorOr<NonnullOwnPtr<Core::Stream::BufferedFile>> open_file(StringView path, Core::Stream::OpenMode mode) | ||||
| inline ErrorOr<NonnullOwnPtr<Core::BufferedFile>> 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::Stream::File::open(path, mode)); | ||||
|     return Core::Stream::BufferedFile::create(move(file)); | ||||
|     auto file = TRY(Core::File::open(path, mode)); | ||||
|     return Core::BufferedFile::create(move(file)); | ||||
| } | ||||
| 
 | ||||
| inline ErrorOr<JsonValue> read_json_file(StringView path) | ||||
| { | ||||
|     auto file = TRY(open_file(path, Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(open_file(path, Core::File::OpenMode::Read)); | ||||
|     auto buffer = TRY(file->read_until_eof()); | ||||
| 
 | ||||
|     return JsonValue::from_string(buffer); | ||||
|  |  | |||
|  | @ -11,6 +11,7 @@ | |||
| #include <AK/Debug.h> | ||||
| #include <AK/LexicalPath.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibIDL/IDLParser.h> | ||||
| #include <LibIDL/Types.h> | ||||
|  | @ -64,7 +65,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_positional_argument(import_base_path, "Import base path", "import-base-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)); | ||||
| 
 | ||||
|     LexicalPath lexical_path(path); | ||||
|     auto& namespace_ = lexical_path.parts_view().at(lexical_path.parts_view().size() - 2); | ||||
|  | @ -74,7 +75,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     if (import_base_path.is_null()) | ||||
|         import_base_path = lexical_path.dirname(); | ||||
| 
 | ||||
|     auto output_file = TRY(Core::Stream::File::open_file_or_standard_stream(output_path, Core::Stream::OpenMode::Write)); | ||||
|     auto output_file = TRY(Core::File::open_file_or_standard_stream(output_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     IDL::Parser parser(path, data, import_base_path); | ||||
|     auto& interface = parser.parse(); | ||||
|  | @ -151,7 +152,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     TRY(output_file->write(output_builder.string_view().bytes())); | ||||
| 
 | ||||
|     if (!depfile_path.is_null()) { | ||||
|         auto depfile = TRY(Core::Stream::File::open_file_or_standard_stream(depfile_path, Core::Stream::OpenMode::Write)); | ||||
|         auto depfile = TRY(Core::File::open_file_or_standard_stream(depfile_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|         StringBuilder depfile_builder; | ||||
|         depfile_builder.append(depfile_target.is_null() ? output_path : depfile_target); | ||||
|  |  | |||
|  | @ -10,8 +10,8 @@ | |||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibMain/Main.h> | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonObject& enums_data, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& enums_data, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_header_file(JsonObject& enums_data, Core::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& enums_data, Core::File& file); | ||||
| 
 | ||||
| ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||
| { | ||||
|  | @ -29,8 +29,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     VERIFY(json.is_object()); | ||||
|     auto enums_data = json.as_object(); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(Core::Stream::File::open(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::Stream::File::open(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     TRY(generate_header_file(enums_data, *generated_header_file)); | ||||
|     TRY(generate_implementation_file(enums_data, *generated_implementation_file)); | ||||
|  | @ -38,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonObject& enums_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_header_file(JsonObject& enums_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -99,7 +99,7 @@ enum class ValueID; | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& enums_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& enums_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  |  | |||
|  | @ -10,8 +10,8 @@ | |||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibMain/Main.h> | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonObject& media_feature_data, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& media_feature_data, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_header_file(JsonObject& media_feature_data, Core::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& media_feature_data, Core::File& file); | ||||
| 
 | ||||
| ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||
| { | ||||
|  | @ -29,8 +29,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     VERIFY(json.is_object()); | ||||
|     auto media_feature_data = json.as_object(); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(Core::Stream::File::open(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::Stream::File::open(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     TRY(generate_header_file(media_feature_data, *generated_header_file)); | ||||
|     TRY(generate_implementation_file(media_feature_data, *generated_implementation_file)); | ||||
|  | @ -38,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonObject& media_feature_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_header_file(JsonObject& media_feature_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -84,7 +84,7 @@ bool media_feature_accepts_identifier(MediaFeatureID, ValueID); | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& media_feature_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& media_feature_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  |  | |||
|  | @ -11,8 +11,8 @@ | |||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibMain/Main.h> | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonObject& properties, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& properties, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_header_file(JsonObject& properties, Core::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& properties, Core::File& file); | ||||
| 
 | ||||
| ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||
| { | ||||
|  | @ -30,8 +30,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     VERIFY(json.is_object()); | ||||
|     auto properties = json.as_object(); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(Core::Stream::File::open(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::Stream::File::open(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     TRY(generate_header_file(properties, *generated_header_file)); | ||||
|     TRY(generate_implementation_file(properties, *generated_implementation_file)); | ||||
|  | @ -39,7 +39,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonObject& properties, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_header_file(JsonObject& properties, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -143,7 +143,7 @@ struct Traits<Web::CSS::PropertyID> : public GenericTraits<Web::CSS::PropertyID> | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& properties, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& properties, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  |  | |||
|  | @ -11,8 +11,8 @@ | |||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibMain/Main.h> | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonObject& transforms_data, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& transforms_data, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_header_file(JsonObject& transforms_data, Core::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& transforms_data, Core::File& file); | ||||
| 
 | ||||
| ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||
| { | ||||
|  | @ -30,8 +30,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     VERIFY(json.is_object()); | ||||
|     auto transforms_data = json.as_object(); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(Core::Stream::File::open(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::Stream::File::open(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     TRY(generate_header_file(transforms_data, *generated_header_file)); | ||||
|     TRY(generate_implementation_file(transforms_data, *generated_implementation_file)); | ||||
|  | @ -48,7 +48,7 @@ static DeprecatedString title_casify_transform_function(StringView input) | |||
|     return builder.to_deprecated_string(); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonObject& transforms_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_header_file(JsonObject& transforms_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -100,7 +100,7 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction); | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& transforms_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_implementation_file(JsonObject& transforms_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  |  | |||
|  | @ -11,8 +11,8 @@ | |||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibMain/Main.h> | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonArray& identifier_data, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonArray& identifier_data, Core::Stream::File& file); | ||||
| ErrorOr<void> generate_header_file(JsonArray& identifier_data, Core::File& file); | ||||
| ErrorOr<void> generate_implementation_file(JsonArray& identifier_data, Core::File& file); | ||||
| 
 | ||||
| ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||
| { | ||||
|  | @ -30,8 +30,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     VERIFY(json.is_array()); | ||||
|     auto identifier_data = json.as_array(); | ||||
| 
 | ||||
|     auto generated_header_file = TRY(Core::Stream::File::open(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::Stream::File::open(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     TRY(generate_header_file(identifier_data, *generated_header_file)); | ||||
|     TRY(generate_implementation_file(identifier_data, *generated_implementation_file)); | ||||
|  | @ -39,7 +39,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_header_file(JsonArray& identifier_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_header_file(JsonArray& identifier_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  | @ -78,7 +78,7 @@ StringView string_from_value_id(ValueID); | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> generate_implementation_file(JsonArray& identifier_data, Core::Stream::File& file) | ||||
| ErrorOr<void> generate_implementation_file(JsonArray& identifier_data, Core::File& file) | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     SourceGenerator generator { builder }; | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ | |||
| #include <AK/SourceGenerator.h> | ||||
| #include <AK/StringBuilder.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibIDL/IDLParser.h> | ||||
| #include <LibIDL/Types.h> | ||||
|  | @ -110,7 +111,7 @@ class @legacy_constructor_class@;)~~~"); | |||
| )~~~"); | ||||
| 
 | ||||
|     auto generated_forward_path = LexicalPath(output_path).append("Forward.h"sv).string(); | ||||
|     auto generated_forward_file = TRY(Core::Stream::File::open(generated_forward_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_forward_file = TRY(Core::File::open(generated_forward_path, Core::File::OpenMode::Write)); | ||||
|     TRY(generated_forward_file->write(generator.as_string_view().bytes())); | ||||
| 
 | ||||
|     return {}; | ||||
|  | @ -224,7 +225,7 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea | |||
| )~~~"); | ||||
| 
 | ||||
|     auto generated_intrinsics_path = LexicalPath(output_path).append("IntrinsicDefinitions.cpp"sv).string(); | ||||
|     auto generated_intrinsics_file = TRY(Core::Stream::File::open(generated_intrinsics_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_intrinsics_file = TRY(Core::File::open(generated_intrinsics_path, Core::File::OpenMode::Write)); | ||||
|     TRY(generated_intrinsics_file->write(generator.as_string_view().bytes())); | ||||
| 
 | ||||
|     return {}; | ||||
|  | @ -250,7 +251,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object&); | |||
| )~~~"); | ||||
| 
 | ||||
|     auto generated_header_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.h", class_name)).string(); | ||||
|     auto generated_header_file = TRY(Core::Stream::File::open(generated_header_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write)); | ||||
|     TRY(generated_header_file->write(generator.as_string_view().bytes())); | ||||
| 
 | ||||
|     return {}; | ||||
|  | @ -332,7 +333,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global) | |||
| )~~~"); | ||||
| 
 | ||||
|     auto generated_implementation_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.cpp", class_name)).string(); | ||||
|     auto generated_implementation_file = TRY(Core::Stream::File::open(generated_implementation_path, Core::Stream::OpenMode::Write)); | ||||
|     auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write)); | ||||
|     TRY(generated_implementation_file->write(generator.as_string_view().bytes())); | ||||
| 
 | ||||
|     return {}; | ||||
|  | @ -359,7 +360,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     // Read in all IDL files, we must own the storage for all of these for the lifetime of the program
 | ||||
|     Vector<DeprecatedString> file_contents; | ||||
|     for (DeprecatedString 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()) { | ||||
|             s_error_string = DeprecatedString::formatted("Unable to open file {}", path); | ||||
|             return Error::from_string_view(s_error_string); | ||||
|  |  | |||
|  | @ -10,6 +10,7 @@ | |||
| #include <AK/DeprecatedString.h> | ||||
| #include <AK/JsonObject.h> | ||||
| #include <AK/Vector.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <ctype.h> | ||||
| 
 | ||||
|  | @ -56,7 +57,7 @@ DeprecatedString snake_casify(DeprecatedString const& dashy_name) | |||
| 
 | ||||
| ErrorOr<JsonValue> read_entire_file_as_json(StringView filename) | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read)); | ||||
|     auto json_size = TRY(file->size()); | ||||
|     auto json_data = TRY(ByteBuffer::create_uninitialized(json_size)); | ||||
|     TRY(file->read_entire_buffer(json_data.bytes())); | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ | |||
| #include <AK/StringBuilder.h> | ||||
| #include <AK/Types.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibMain/Main.h> | ||||
| #include <ctype.h> | ||||
|  | @ -221,7 +222,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     args_parser.add_positional_argument(path, "Path to parser description", "input", 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()); | ||||
|     auto state_machine = parse_state_machine(content); | ||||
| 
 | ||||
|  |  | |||
|  | @ -192,7 +192,7 @@ static Result<Vector<DeprecatedString>, int> run_whiptail(WhiptailMode mode, Vec | |||
|         return return_code; | ||||
|     } | ||||
| 
 | ||||
|     auto file_or_error = Core::Stream::File::adopt_fd(read_fd, Core::Stream::OpenMode::Read); | ||||
|     auto file_or_error = Core::File::adopt_fd(read_fd, Core::File::OpenMode::Read); | ||||
|     if (file_or_error.is_error()) { | ||||
|         warnln("\e[31mError:\e[0m Could not adopt file descriptor for reading: {}", file_or_error.error()); | ||||
|         return -1; | ||||
|  |  | |||
|  | @ -50,7 +50,7 @@ new file mode 100644 | |||
| index 0000000000000000000000000000000000000000..cc0c08cb85a682d66a00f6b48ad2871f83b5e719
 | ||||
| --- /dev/null
 | ||||
| +++ b/src/java.base/serenity/native/libjava/ProcessHandleImpl_serenity.cpp
 | ||||
| @@ -0,0 +1,165 @@
 | ||||
| @@ -0,0 +1,166 @@
 | ||||
| +/*
 | ||||
| + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
 | ||||
| + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 | ||||
|  | @ -89,6 +89,7 @@ index 0000000000000000000000000000000000000000..cc0c08cb85a682d66a00f6b48ad2871f | |||
| +
 | ||||
| +#include <AK/JsonArray.h>
 | ||||
| +#include <LibCore/DeprecatedFile.h>
 | ||||
| +#include <LibCore/File.h>
 | ||||
| +#include <LibCore/ProcessStatisticsReader.h>
 | ||||
| +#include <LibCore/Stream.h>
 | ||||
| +#include <stdio.h>
 | ||||
|  | @ -189,7 +190,7 @@ index 0000000000000000000000000000000000000000..cc0c08cb85a682d66a00f6b48ad2871f | |||
| +    unix_getUserInfo(env, jinfo, proc.pid);
 | ||||
| +    JNU_CHECK_EXCEPTION(env);
 | ||||
| +
 | ||||
| +    auto cmdline_file = JAVA_TRY(Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/cmdline", pid), Core::Stream::OpenMode::Read), "Unable to open /proc/pid/cmdline"sv);
 | ||||
| +    auto cmdline_file = JAVA_TRY(Core::File::open(DeprecatedString::formatted("/proc/{}/cmdline", pid), Core::File::OpenMode::Read), "Unable to open /proc/pid/cmdline"sv);
 | ||||
| +    auto contents = JAVA_TRY(cmdline_file->read_until_eof(), "Unable to read /proc/pid/cmdline"sv);
 | ||||
| +    auto cmdline = JAVA_TRY(JsonValue::from_string(contents), "Invalid JSON in /proc/pid/cmdline"sv);
 | ||||
| +
 | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ | |||
| #include <LibTest/TestCase.h> | ||||
| 
 | ||||
| #include <LibCompress/Brotli.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| 
 | ||||
| static void run_test(StringView const file_name) | ||||
|  | @ -18,12 +19,12 @@ static void run_test(StringView const file_name) | |||
|     DeprecatedString path = DeprecatedString::formatted("brotli-test-files/{}", file_name); | ||||
| #endif | ||||
| 
 | ||||
|     auto cmp_file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); | ||||
|     auto cmp_file = MUST(Core::File::open(path, Core::File::OpenMode::Read)); | ||||
|     auto cmp_data = MUST(cmp_file->read_until_eof()); | ||||
| 
 | ||||
|     DeprecatedString path_compressed = DeprecatedString::formatted("{}.br", path); | ||||
| 
 | ||||
|     auto file = MUST(Core::Stream::File::open(path_compressed, Core::Stream::OpenMode::Read)); | ||||
|     auto file = MUST(Core::File::open(path_compressed, Core::File::OpenMode::Read)); | ||||
|     auto brotli_stream = Compress::BrotliDecompressionStream { *file }; | ||||
|     auto data = MUST(brotli_stream.read_until_eof()); | ||||
| 
 | ||||
|  | @ -96,7 +97,7 @@ TEST_CASE(brotli_decompress_zero_one_bin) | |||
| 
 | ||||
|     DeprecatedString path_compressed = DeprecatedString::formatted("{}.br", path); | ||||
| 
 | ||||
|     auto file = MUST(Core::Stream::File::open(path_compressed, Core::Stream::OpenMode::Read)); | ||||
|     auto file = MUST(Core::File::open(path_compressed, Core::File::OpenMode::Read)); | ||||
|     auto brotli_stream = Compress::BrotliDecompressionStream { *file }; | ||||
| 
 | ||||
|     u8 buffer_raw[4096]; | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
| #include <AK/MaybeOwned.h> | ||||
| #include <AK/String.h> | ||||
| #include <LibCore/EventLoop.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/LocalServer.h> | ||||
| #include <LibCore/Socket.h> | ||||
| #include <LibCore/Stream.h> | ||||
|  | @ -23,7 +24,7 @@ | |||
| 
 | ||||
| TEST_CASE(file_open) | ||||
| { | ||||
|     auto maybe_file = Core::Stream::File::open("/tmp/file-open-test.txt"sv, Core::Stream::OpenMode::Write); | ||||
|     auto maybe_file = Core::File::open("/tmp/file-open-test.txt"sv, Core::File::OpenMode::Write); | ||||
|     if (maybe_file.is_error()) { | ||||
|         warnln("Failed to open the file: {}", strerror(maybe_file.error().code())); | ||||
|         VERIFY_NOT_REACHED(); | ||||
|  | @ -41,7 +42,7 @@ TEST_CASE(file_open) | |||
| 
 | ||||
| TEST_CASE(file_write_bytes) | ||||
| { | ||||
|     auto maybe_file = Core::Stream::File::open("/tmp/file-write-bytes-test.txt"sv, Core::Stream::OpenMode::Write); | ||||
|     auto maybe_file = Core::File::open("/tmp/file-write-bytes-test.txt"sv, Core::File::OpenMode::Write); | ||||
|     auto file = maybe_file.release_value(); | ||||
| 
 | ||||
|     constexpr auto some_words = "These are some words"sv; | ||||
|  | @ -54,7 +55,7 @@ constexpr auto expected_buffer_contents = "<small>(Please consider transla | |||
| 
 | ||||
| TEST_CASE(file_read_bytes) | ||||
| { | ||||
|     auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::Stream::OpenMode::Read); | ||||
|     auto maybe_file = Core::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::File::OpenMode::Read); | ||||
|     EXPECT(!maybe_file.is_error()); | ||||
|     auto file = maybe_file.release_value(); | ||||
| 
 | ||||
|  | @ -76,7 +77,7 @@ constexpr auto expected_seek_contents3 = "levels of advanc"sv; | |||
| 
 | ||||
| TEST_CASE(file_seeking_around) | ||||
| { | ||||
|     auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::Stream::OpenMode::Read); | ||||
|     auto maybe_file = Core::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::File::OpenMode::Read); | ||||
|     EXPECT(!maybe_file.is_error()); | ||||
|     auto file = maybe_file.release_value(); | ||||
| 
 | ||||
|  | @ -109,7 +110,7 @@ TEST_CASE(file_adopt_fd) | |||
|     int rc = ::open("/usr/Tests/LibCore/long_lines.txt", O_RDONLY); | ||||
|     EXPECT(rc >= 0); | ||||
| 
 | ||||
|     auto maybe_file = Core::Stream::File::adopt_fd(rc, Core::Stream::OpenMode::Read); | ||||
|     auto maybe_file = Core::File::adopt_fd(rc, Core::File::OpenMode::Read); | ||||
|     EXPECT(!maybe_file.is_error()); | ||||
|     auto file = maybe_file.release_value(); | ||||
| 
 | ||||
|  | @ -131,14 +132,14 @@ TEST_CASE(file_adopt_fd) | |||
| 
 | ||||
| TEST_CASE(file_adopt_invalid_fd) | ||||
| { | ||||
|     auto maybe_file = Core::Stream::File::adopt_fd(-1, Core::Stream::OpenMode::Read); | ||||
|     auto maybe_file = Core::File::adopt_fd(-1, Core::File::OpenMode::Read); | ||||
|     EXPECT(maybe_file.is_error()); | ||||
|     EXPECT_EQ(maybe_file.error().code(), EBADF); | ||||
| } | ||||
| 
 | ||||
| TEST_CASE(file_truncate) | ||||
| { | ||||
|     auto maybe_file = Core::Stream::File::open("/tmp/file-truncate-test.txt"sv, Core::Stream::OpenMode::Write); | ||||
|     auto maybe_file = Core::File::open("/tmp/file-truncate-test.txt"sv, Core::File::OpenMode::Write); | ||||
|     auto file = maybe_file.release_value(); | ||||
| 
 | ||||
|     EXPECT(!file->truncate(999).is_error()); | ||||
|  | @ -420,9 +421,9 @@ TEST_CASE(local_socket_write) | |||
| 
 | ||||
| TEST_CASE(buffered_long_file_read) | ||||
| { | ||||
|     auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::Stream::OpenMode::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::Stream::BufferedFile::create(maybe_file.release_value()); | ||||
|     auto maybe_buffered_file = Core::BufferedFile::create(maybe_file.release_value()); | ||||
|     EXPECT(!maybe_buffered_file.is_error()); | ||||
|     auto file = maybe_buffered_file.release_value(); | ||||
| 
 | ||||
|  | @ -442,9 +443,9 @@ TEST_CASE(buffered_long_file_read) | |||
| 
 | ||||
| TEST_CASE(buffered_small_file_read) | ||||
| { | ||||
|     auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/small.txt"sv, Core::Stream::OpenMode::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::Stream::BufferedFile::create(maybe_file.release_value()); | ||||
|     auto maybe_buffered_file = Core::BufferedFile::create(maybe_file.release_value()); | ||||
|     EXPECT(!maybe_buffered_file.is_error()); | ||||
|     auto file = maybe_buffered_file.release_value(); | ||||
| 
 | ||||
|  | @ -471,8 +472,8 @@ TEST_CASE(buffered_small_file_read) | |||
| 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::Stream::File::open("/usr/Tests/LibCore/small.txt"sv, Core::Stream::OpenMode::Read).release_value(); | ||||
|     auto buffered_file = Core::Stream::BufferedFile::create(move(file), 12).release_value(); | ||||
|     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(); | ||||
| 
 | ||||
|     // Initial state.
 | ||||
|     { | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
| 
 | ||||
| #include <AK/LexicalPath.h> | ||||
| #include <LibCore/DirIterator.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibCpp/Parser.h> | ||||
| #include <LibTest/TestCase.h> | ||||
|  | @ -15,7 +16,7 @@ constexpr char TESTS_ROOT_DIR[] = "/home/anon/Tests/cpp-tests/parser"; | |||
| 
 | ||||
| static DeprecatedString read_all(DeprecatedString const& path) | ||||
| { | ||||
|     auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); | ||||
|     auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read)); | ||||
|     auto file_size = MUST(file->size()); | ||||
|     auto content = MUST(ByteBuffer::create_uninitialized(file_size)); | ||||
|     MUST(file->read_entire_buffer(content.bytes())); | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
| 
 | ||||
| #include <AK/LexicalPath.h> | ||||
| #include <LibCore/DirIterator.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibCpp/Parser.h> | ||||
| #include <LibTest/TestCase.h> | ||||
|  | @ -14,7 +15,7 @@ constexpr char TESTS_ROOT_DIR[] = "/home/anon/Tests/cpp-tests/preprocessor"; | |||
| 
 | ||||
| static DeprecatedString read_all(DeprecatedString const& path) | ||||
| { | ||||
|     auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); | ||||
|     auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read)); | ||||
|     auto file_size = MUST(file->size()); | ||||
|     auto content = MUST(ByteBuffer::create_uninitialized(file_size)); | ||||
|     MUST(file->read_entire_buffer(content.bytes())); | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ | |||
| 
 | ||||
| #include <AK/DeprecatedString.h> | ||||
| #include <AK/LexicalPath.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibGL/GL/gl.h> | ||||
| #include <LibGL/GLContext.h> | ||||
|  | @ -36,7 +37,7 @@ static void expect_bitmap_equals_reference(Gfx::Bitmap const& bitmap, StringView | |||
|     if constexpr (SAVE_OUTPUT) { | ||||
|         auto target_path = LexicalPath("/home/anon").append(reference_filename); | ||||
|         auto qoi_buffer = Gfx::QOIWriter::encode(bitmap); | ||||
|         auto qoi_output_stream = MUST(Core::Stream::File::open(target_path.string(), Core::Stream::OpenMode::Write)); | ||||
|         auto qoi_output_stream = MUST(Core::File::open(target_path.string(), Core::File::OpenMode::Write)); | ||||
|         MUST(qoi_output_stream->write_entire_buffer(qoi_buffer)); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -14,6 +14,7 @@ | |||
| #include <AK/Vector.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/DeprecatedFile.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Process.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibCore/System.h> | ||||
|  | @ -131,16 +132,16 @@ public: | |||
|         TRY(Core::System::close(write_pipe_fds[0])); | ||||
|         TRY(Core::System::close(read_pipe_fds[1])); | ||||
| 
 | ||||
|         auto infile = TRY(Core::Stream::File::adopt_fd(read_pipe_fds[0], Core::Stream::OpenMode::Read)); | ||||
|         auto infile = TRY(Core::File::adopt_fd(read_pipe_fds[0], Core::File::OpenMode::Read)); | ||||
| 
 | ||||
|         auto outfile = TRY(Core::Stream::File::adopt_fd(write_pipe_fds[1], Core::Stream::OpenMode::Write)); | ||||
|         auto outfile = TRY(Core::File::adopt_fd(write_pipe_fds[1], Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|         runner_kill.disarm(); | ||||
| 
 | ||||
|         return make<Test262RunnerHandler>(pid, move(infile), move(outfile)); | ||||
|     } | ||||
| 
 | ||||
|     Test262RunnerHandler(pid_t pid, NonnullOwnPtr<Core::Stream::File> in_file, NonnullOwnPtr<Core::Stream::File> out_file) | ||||
|     Test262RunnerHandler(pid_t pid, NonnullOwnPtr<Core::File> in_file, NonnullOwnPtr<Core::File> out_file) | ||||
|         : m_pid(pid) | ||||
|         , m_input(move(in_file)) | ||||
|         , m_output(move(out_file)) | ||||
|  | @ -218,8 +219,8 @@ public: | |||
| 
 | ||||
| public: | ||||
|     pid_t m_pid; | ||||
|     NonnullOwnPtr<Core::Stream::File> m_input; | ||||
|     NonnullOwnPtr<Core::Stream::File> m_output; | ||||
|     NonnullOwnPtr<Core::File> m_input; | ||||
|     NonnullOwnPtr<Core::File> m_output; | ||||
| }; | ||||
| 
 | ||||
| static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString> files, size_t offset, StringView command, char const* const arguments[]) | ||||
|  | @ -411,7 +412,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
| void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<DeprecatedString> const& paths, StringView per_file_name, double time_taken_in_ms) | ||||
| { | ||||
| 
 | ||||
|     auto file_or_error = Core::Stream::File::open(per_file_name, Core::Stream::OpenMode::Write); | ||||
|     auto file_or_error = Core::File::open(per_file_name, Core::File::OpenMode::Write); | ||||
|     if (file_or_error.is_error()) { | ||||
|         warnln("Failed to open per file for writing at {}: {}", per_file_name, file_or_error.error().string_literal()); | ||||
|         return; | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ | |||
| #include <AK/ScopeGuard.h> | ||||
| #include <AK/Vector.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibJS/Bytecode/BasicBlock.h> | ||||
| #include <LibJS/Bytecode/Generator.h> | ||||
|  | @ -139,7 +140,7 @@ static Result<StringView, TestError> read_harness_file(StringView harness_file) | |||
| { | ||||
|     auto cache = s_cached_harness_files.find(harness_file); | ||||
|     if (cache == s_cached_harness_files.end()) { | ||||
|         auto file_or_error = Core::Stream::File::open(DeprecatedString::formatted("{}{}", s_harness_file_directory, harness_file), Core::Stream::OpenMode::Read); | ||||
|         auto file_or_error = Core::File::open(DeprecatedString::formatted("{}{}", s_harness_file_directory, harness_file), Core::File::OpenMode::Read); | ||||
|         if (file_or_error.is_error()) { | ||||
|             return TestError { | ||||
|                 NegativePhase::Harness, | ||||
|  | @ -679,12 +680,12 @@ int main(int argc, char** argv) | |||
| #define DISARM_TIMER() \ | ||||
|     alarm(0) | ||||
| 
 | ||||
|     auto standard_input_or_error = Core::Stream::File::standard_input(); | ||||
|     auto standard_input_or_error = Core::File::standard_input(); | ||||
|     if (standard_input_or_error.is_error()) | ||||
|         return exit_setup_input_failure; | ||||
| 
 | ||||
|     Array<u8, 1024> input_buffer {}; | ||||
|     auto buffered_standard_input_or_error = Core::Stream::BufferedFile::create(standard_input_or_error.release_value()); | ||||
|     auto buffered_standard_input_or_error = Core::BufferedFile::create(standard_input_or_error.release_value()); | ||||
|     if (buffered_standard_input_or_error.is_error()) | ||||
|         return exit_setup_input_failure; | ||||
| 
 | ||||
|  | @ -708,7 +709,7 @@ int main(int argc, char** argv) | |||
|             VERIFY(!s_harness_file_directory.is_empty()); | ||||
|         } | ||||
| 
 | ||||
|         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("Could not open file: {}", path); | ||||
|             return exit_read_file_failure; | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
| #include <AK/JsonArray.h> | ||||
| #include <AK/JsonObject.h> | ||||
| #include <AK/JsonParser.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibMarkdown/Document.h> | ||||
| #include <LibTest/TestCase.h> | ||||
|  | @ -15,9 +16,9 @@ | |||
| 
 | ||||
| TEST_SETUP | ||||
| { | ||||
|     auto file_or_error = Core::Stream::File::open("/home/anon/Tests/commonmark.spec.json"sv, Core::Stream::OpenMode::Read); | ||||
|     auto file_or_error = Core::File::open("/home/anon/Tests/commonmark.spec.json"sv, Core::File::OpenMode::Read); | ||||
|     if (file_or_error.is_error()) | ||||
|         file_or_error = Core::Stream::File::open("./commonmark.spec.json"sv, Core::Stream::OpenMode::Read); | ||||
|         file_or_error = Core::File::open("./commonmark.spec.json"sv, Core::File::OpenMode::Read); | ||||
|     VERIFY(!file_or_error.is_error()); | ||||
|     auto file = file_or_error.release_value(); | ||||
|     auto file_size = MUST(file->size()); | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile) | |||
| { | ||||
|     auto& realm = *vm.current_realm(); | ||||
|     auto filename = TRY(vm.argument(0).to_deprecated_string(vm)); | ||||
|     auto file = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read); | ||||
|     auto file = Core::File::open(filename, Core::File::OpenMode::Read); | ||||
|     if (file.is_error()) | ||||
|         return vm.throw_completion<JS::TypeError>(strerror(file.error().code())); | ||||
| 
 | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
| 
 | ||||
| #include <LibTest/TestCase.h> | ||||
| 
 | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibWeb/HTML/Parser/HTMLTokenizer.h> | ||||
| 
 | ||||
|  | @ -208,7 +209,7 @@ TEST_CASE(regression) | |||
|     StringView path = "tokenizer-test.html"sv; | ||||
| #endif | ||||
| 
 | ||||
|     auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); | ||||
|     auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read)); | ||||
|     auto file_size = MUST(file->size()); | ||||
|     auto content = MUST(ByteBuffer::create_uninitialized(file_size)); | ||||
|     MUST(file->read(content.bytes())); | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
|  */ | ||||
| 
 | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibCore/System.h> | ||||
| #include <LibGUI/Action.h> | ||||
|  | @ -107,7 +108,7 @@ private: | |||
|     { | ||||
|         StringBuilder adapter_info; | ||||
| 
 | ||||
|         auto file_or_error = Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read); | ||||
|         auto file_or_error = Core::File::open("/sys/kernel/net/adapters"sv, Core::File::OpenMode::Read); | ||||
|         if (file_or_error.is_error()) { | ||||
|             dbgln("Error: Could not open /sys/kernel/net/adapters: {}", file_or_error.error()); | ||||
|             return ""; | ||||
|  |  | |||
|  | @ -144,13 +144,13 @@ private: | |||
|         GUI::Process::spawn_or_show_error(window(), "/bin/SystemMonitor"sv, Array { "-t", m_graph_type == GraphType::Network ? "network" : "graphs" }); | ||||
|     } | ||||
| 
 | ||||
|     ErrorOr<JsonValue> get_data_as_json(OwnPtr<Core::Stream::File>& file, StringView filename) | ||||
|     ErrorOr<JsonValue> get_data_as_json(OwnPtr<Core::File>& file, StringView filename) | ||||
|     { | ||||
|         if (file) { | ||||
|             // Seeking to the beginning causes a data refresh!
 | ||||
|             TRY(file->seek(0, SeekMode::SetPosition)); | ||||
|         } else { | ||||
|             file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read)); | ||||
|             file = TRY(Core::File::open(filename, Core::File::OpenMode::Read)); | ||||
|         } | ||||
| 
 | ||||
|         auto file_contents = TRY(file->read_until_eof()); | ||||
|  | @ -231,9 +231,9 @@ private: | |||
|     static constexpr u64 const scale_unit = 8000; | ||||
|     u64 m_current_scale { scale_unit }; | ||||
|     DeprecatedString m_tooltip; | ||||
|     OwnPtr<Core::Stream::File> m_proc_stat; | ||||
|     OwnPtr<Core::Stream::File> m_proc_mem; | ||||
|     OwnPtr<Core::Stream::File> m_proc_net; | ||||
|     OwnPtr<Core::File> m_proc_stat; | ||||
|     OwnPtr<Core::File> m_proc_mem; | ||||
|     OwnPtr<Core::File> m_proc_net; | ||||
| }; | ||||
| 
 | ||||
| ErrorOr<int> serenity_main(Main::Arguments arguments) | ||||
|  |  | |||
|  | @ -488,7 +488,7 @@ ErrorOr<void> BrowserWindow::load_search_engines(GUI::Menu& settings_menu) | |||
|     m_search_engine_actions.add_action(*m_disable_search_engine_action); | ||||
|     m_disable_search_engine_action->set_checked(true); | ||||
| 
 | ||||
|     auto search_engines_file = TRY(Core::Stream::File::open(Browser::search_engines_file_path(), Core::Stream::OpenMode::Read)); | ||||
|     auto search_engines_file = TRY(Core::File::open(Browser::search_engines_file_path(), Core::File::OpenMode::Read)); | ||||
|     auto file_size = TRY(search_engines_file->size()); | ||||
|     auto buffer = TRY(ByteBuffer::create_uninitialized(file_size)); | ||||
|     if (!search_engines_file->read_entire_buffer(buffer).is_error()) { | ||||
|  | @ -775,7 +775,7 @@ ErrorOr<void> BrowserWindow::take_screenshot(ScreenshotType type) | |||
| 
 | ||||
|     auto encoded = TRY(Gfx::PNGWriter::encode(*bitmap.bitmap())); | ||||
| 
 | ||||
|     auto screenshot_file = TRY(Core::Stream::File::open(path.string(), Core::Stream::OpenMode::Write)); | ||||
|     auto screenshot_file = TRY(Core::File::open(path.string(), Core::File::OpenMode::Write)); | ||||
|     TRY(screenshot_file->write(encoded)); | ||||
| 
 | ||||
|     return {}; | ||||
|  |  | |||
|  | @ -47,7 +47,7 @@ DownloadWidget::DownloadWidget(const URL& url) | |||
|     }; | ||||
| 
 | ||||
|     { | ||||
|         auto file_or_error = Core::Stream::File::open(m_destination_path, Core::Stream::OpenMode::Write); | ||||
|         auto file_or_error = Core::File::open(m_destination_path, Core::File::OpenMode::Write); | ||||
|         if (file_or_error.is_error()) { | ||||
|             GUI::MessageBox::show(window(), DeprecatedString::formatted("Cannot open {} for writing", m_destination_path), "Download failed"sv, GUI::MessageBox::Type::Error); | ||||
|             window()->close(); | ||||
|  |  | |||
|  | @ -38,7 +38,7 @@ private: | |||
|     RefPtr<GUI::Button> m_close_button; | ||||
|     RefPtr<GUI::CheckBox> m_close_on_finish_checkbox; | ||||
|     RefPtr<GUI::ImageWidget> m_browser_image; | ||||
|     OwnPtr<Core::Stream::File> m_output_file_stream; | ||||
|     OwnPtr<Core::File> m_output_file_stream; | ||||
|     Core::ElapsedTimer m_elapsed_timer; | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -45,8 +45,8 @@ DeprecatedString g_webdriver_content_ipc_path; | |||
| 
 | ||||
| static ErrorOr<void> load_content_filters() | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(DeprecatedString::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::Stream::OpenMode::Read)); | ||||
|     auto ad_filter_list = TRY(Core::Stream::BufferedFile::create(move(file))); | ||||
|     auto file = TRY(Core::File::open(DeprecatedString::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::File::OpenMode::Read)); | ||||
|     auto ad_filter_list = TRY(Core::BufferedFile::create(move(file))); | ||||
|     auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); | ||||
|     while (TRY(ad_filter_list->can_read_line())) { | ||||
|         auto line = TRY(ad_filter_list->read_line(buffer)); | ||||
|  |  | |||
|  | @ -28,8 +28,8 @@ static DeprecatedString filter_list_file_path() | |||
| ErrorOr<void> DomainListModel::load() | ||||
| { | ||||
|     // FIXME: This should be somewhat shared with Browser.
 | ||||
|     auto file = TRY(Core::Stream::File::open(filter_list_file_path(), Core::Stream::OpenMode::Read)); | ||||
|     auto content_filter_list = TRY(Core::Stream::BufferedFile::create(move(file))); | ||||
|     auto file = TRY(Core::File::open(filter_list_file_path(), Core::File::OpenMode::Read)); | ||||
|     auto content_filter_list = TRY(Core::BufferedFile::create(move(file))); | ||||
|     auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); | ||||
|     while (TRY(content_filter_list->can_read_line())) { | ||||
|         auto line = TRY(content_filter_list->read_line(buffer)); | ||||
|  | @ -50,7 +50,7 @@ ErrorOr<void> DomainListModel::save() | |||
|     for (auto const& domain : m_domain_list) | ||||
|         TRY(builder.try_appendff("{}\n", domain)); | ||||
| 
 | ||||
|     auto file = TRY(Core::Stream::File::open(filter_list_file_path(), Core::Stream::OpenMode::Write)); | ||||
|     auto file = TRY(Core::File::open(filter_list_file_path(), Core::File::OpenMode::Write)); | ||||
|     TRY(file->write(builder.to_byte_buffer().bytes())); | ||||
|     return {}; | ||||
| } | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ ThemePreviewWidget::ThemePreviewWidget(Gfx::Palette const& palette) | |||
| 
 | ||||
| ErrorOr<void> ThemePreviewWidget::set_theme(DeprecatedString path) | ||||
| { | ||||
|     auto config_file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); | ||||
|     auto config_file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); | ||||
|     TRY(set_theme_from_file(path, move(config_file))); | ||||
|     return {}; | ||||
| } | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ | |||
| 
 | ||||
| namespace FileManager { | ||||
| 
 | ||||
| FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation, NonnullOwnPtr<Core::Stream::BufferedFile> helper_pipe, int helper_pipe_fd) | ||||
| FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation, NonnullOwnPtr<Core::BufferedFile> helper_pipe, int helper_pipe_fd) | ||||
|     : m_operation(operation) | ||||
|     , m_helper_pipe(move(helper_pipe)) | ||||
| { | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
| 
 | ||||
| #include "FileUtils.h" | ||||
| #include <LibCore/ElapsedTimer.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibGUI/Widget.h> | ||||
| 
 | ||||
|  | @ -21,7 +22,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::Stream::BufferedFile> helper_pipe, int helper_pipe_fd); | ||||
|     FileOperationProgressWidget(FileOperation, NonnullOwnPtr<Core::BufferedFile> helper_pipe, int helper_pipe_fd); | ||||
| 
 | ||||
|     void did_finish(); | ||||
|     void did_error(StringView message); | ||||
|  | @ -34,6 +35,6 @@ private: | |||
| 
 | ||||
|     FileOperation m_operation; | ||||
|     RefPtr<Core::Notifier> m_notifier; | ||||
|     OwnPtr<Core::Stream::BufferedFile> m_helper_pipe; | ||||
|     OwnPtr<Core::BufferedFile> m_helper_pipe; | ||||
| }; | ||||
| } | ||||
|  |  | |||
|  | @ -99,8 +99,8 @@ ErrorOr<void> run_file_operation(FileOperation operation, Vector<DeprecatedStrin | |||
|         VERIFY_NOT_REACHED(); | ||||
|     } | ||||
| 
 | ||||
|     auto pipe_input_file = TRY(Core::Stream::File::adopt_fd(pipe_fds[0], Core::Stream::OpenMode::Read)); | ||||
|     auto buffered_pipe = TRY(Core::Stream::BufferedFile::create(move(pipe_input_file))); | ||||
|     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))); | ||||
| 
 | ||||
|     (void)TRY(window->set_main_widget<FileOperationProgressWidget>(operation, move(buffered_pipe), pipe_fds[0])); | ||||
|     window->resize(320, 190); | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
|  */ | ||||
| 
 | ||||
| #include "HexDocument.h" | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| 
 | ||||
| void HexDocument::set(size_t position, u8 value) | ||||
|  | @ -58,7 +59,7 @@ void HexDocumentMemory::clear_changes() | |||
|     m_changes.clear(); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> HexDocumentMemory::write_to_file(Core::Stream::File& file) | ||||
| ErrorOr<void> HexDocumentMemory::write_to_file(Core::File& file) | ||||
| { | ||||
|     TRY(file.seek(0, SeekMode::SetPosition)); | ||||
|     TRY(file.write(m_buffer)); | ||||
|  | @ -69,7 +70,7 @@ ErrorOr<void> HexDocumentMemory::write_to_file(Core::Stream::File& file) | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<NonnullOwnPtr<HexDocumentFile>> HexDocumentFile::create(NonnullOwnPtr<Core::Stream::File> file) | ||||
| ErrorOr<NonnullOwnPtr<HexDocumentFile>> HexDocumentFile::create(NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     auto document = TRY(adopt_nonnull_own_or_enomem(new HexDocumentFile(move(file)))); | ||||
|     TRY(document->initialize_internal_state()); | ||||
|  | @ -77,7 +78,7 @@ ErrorOr<NonnullOwnPtr<HexDocumentFile>> HexDocumentFile::create(NonnullOwnPtr<Co | |||
|     return document; | ||||
| } | ||||
| 
 | ||||
| HexDocumentFile::HexDocumentFile(NonnullOwnPtr<Core::Stream::File> file) | ||||
| HexDocumentFile::HexDocumentFile(NonnullOwnPtr<Core::File> file) | ||||
|     : m_file(move(file)) | ||||
| { | ||||
| } | ||||
|  | @ -94,7 +95,7 @@ ErrorOr<void> HexDocumentFile::write_to_file() | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> HexDocumentFile::write_to_file(Core::Stream::File& file) | ||||
| ErrorOr<void> HexDocumentFile::write_to_file(Core::File& file) | ||||
| { | ||||
|     TRY(file.truncate(size())); | ||||
| 
 | ||||
|  | @ -149,7 +150,7 @@ void HexDocumentFile::clear_changes() | |||
|     m_changes.clear(); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> HexDocumentFile::set_file(NonnullOwnPtr<Core::Stream::File> file) | ||||
| ErrorOr<void> HexDocumentFile::set_file(NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     m_file = move(file); | ||||
|     TRY(initialize_internal_state()); | ||||
|  | @ -171,7 +172,7 @@ ErrorOr<void> HexDocumentFile::initialize_internal_state() | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| NonnullOwnPtr<Core::Stream::File> const& HexDocumentFile::file() const | ||||
| NonnullOwnPtr<Core::File> const& HexDocumentFile::file() const | ||||
| { | ||||
|     return m_file; | ||||
| } | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ public: | |||
|     size_t size() const override; | ||||
|     Type type() const override; | ||||
|     void clear_changes() override; | ||||
|     ErrorOr<void> write_to_file(Core::Stream::File& file); | ||||
|     ErrorOr<void> write_to_file(Core::File& file); | ||||
| 
 | ||||
| private: | ||||
|     ByteBuffer m_buffer; | ||||
|  | @ -60,16 +60,16 @@ private: | |||
| 
 | ||||
| class HexDocumentFile final : public HexDocument { | ||||
| public: | ||||
|     static ErrorOr<NonnullOwnPtr<HexDocumentFile>> create(NonnullOwnPtr<Core::Stream::File> file); | ||||
|     static ErrorOr<NonnullOwnPtr<HexDocumentFile>> create(NonnullOwnPtr<Core::File> file); | ||||
|     virtual ~HexDocumentFile() = default; | ||||
| 
 | ||||
|     HexDocumentFile(HexDocumentFile&&) = default; | ||||
|     HexDocumentFile(HexDocumentFile const&) = delete; | ||||
| 
 | ||||
|     ErrorOr<void> set_file(NonnullOwnPtr<Core::Stream::File> file); | ||||
|     NonnullOwnPtr<Core::Stream::File> const& file() const; | ||||
|     ErrorOr<void> set_file(NonnullOwnPtr<Core::File> file); | ||||
|     NonnullOwnPtr<Core::File> const& file() const; | ||||
|     ErrorOr<void> write_to_file(); | ||||
|     ErrorOr<void> write_to_file(Core::Stream::File& file); | ||||
|     ErrorOr<void> write_to_file(Core::File& file); | ||||
|     Cell get(size_t position) override; | ||||
|     u8 get_unchanged(size_t position) override; | ||||
|     size_t size() const override; | ||||
|  | @ -77,12 +77,12 @@ public: | |||
|     void clear_changes() override; | ||||
| 
 | ||||
| private: | ||||
|     explicit HexDocumentFile(NonnullOwnPtr<Core::Stream::File> file); | ||||
|     explicit HexDocumentFile(NonnullOwnPtr<Core::File> file); | ||||
|     ErrorOr<void> initialize_internal_state(); | ||||
| 
 | ||||
|     void ensure_position_in_buffer(size_t position); | ||||
| 
 | ||||
|     NonnullOwnPtr<Core::Stream::File> m_file; | ||||
|     NonnullOwnPtr<Core::File> m_file; | ||||
|     size_t m_file_size; | ||||
| 
 | ||||
|     Array<u8, 2048> m_buffer; | ||||
|  |  | |||
|  | @ -63,7 +63,7 @@ ErrorOr<void> HexEditor::open_new_file(size_t size) | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| void HexEditor::open_file(NonnullOwnPtr<Core::Stream::File> file) | ||||
| void HexEditor::open_file(NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     m_document = HexDocumentFile::create(move(file)).release_value_but_fixme_should_propagate_errors(); | ||||
|     set_content_length(m_document->size()); | ||||
|  | @ -136,7 +136,7 @@ void HexEditor::set_selection(size_t position, size_t length) | |||
|     update_status(); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> HexEditor::save_as(NonnullOwnPtr<Core::Stream::File> new_file) | ||||
| ErrorOr<void> HexEditor::save_as(NonnullOwnPtr<Core::File> new_file) | ||||
| { | ||||
|     if (m_document->type() == HexDocument::Type::File) { | ||||
|         auto& file_document = static_cast<HexDocumentFile&>(*m_document); | ||||
|  |  | |||
|  | @ -35,10 +35,10 @@ public: | |||
| 
 | ||||
|     size_t buffer_size() const { return m_document->size(); } | ||||
|     ErrorOr<void> open_new_file(size_t size); | ||||
|     void open_file(NonnullOwnPtr<Core::Stream::File> file); | ||||
|     void open_file(NonnullOwnPtr<Core::File> file); | ||||
|     ErrorOr<void> fill_selection(u8 fill_byte); | ||||
|     Optional<u8> get_byte(size_t position); | ||||
|     ErrorOr<void> save_as(NonnullOwnPtr<Core::Stream::File>); | ||||
|     ErrorOr<void> save_as(NonnullOwnPtr<Core::File>); | ||||
|     ErrorOr<void> save(); | ||||
| 
 | ||||
|     bool undo(); | ||||
|  |  | |||
|  | @ -121,7 +121,7 @@ HexEditorWidget::HexEditorWidget() | |||
|         if (!request_close()) | ||||
|             return; | ||||
| 
 | ||||
|         auto response = FileSystemAccessClient::Client::the().open_file(window(), {}, Core::StandardPaths::home_directory(), Core::Stream::OpenMode::ReadWrite); | ||||
|         auto response = FileSystemAccessClient::Client::the().open_file(window(), {}, Core::StandardPaths::home_directory(), Core::File::OpenMode::ReadWrite); | ||||
|         if (response.is_error()) | ||||
|             return; | ||||
| 
 | ||||
|  | @ -142,7 +142,7 @@ HexEditorWidget::HexEditorWidget() | |||
|     }); | ||||
| 
 | ||||
|     m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) { | ||||
|         auto response = FileSystemAccessClient::Client::the().save_file(window(), m_name, m_extension, Core::Stream::OpenMode::ReadWrite | Core::Stream::OpenMode::Truncate); | ||||
|         auto response = FileSystemAccessClient::Client::the().save_file(window(), m_name, m_extension, Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate); | ||||
|         if (response.is_error()) | ||||
|             return; | ||||
|         auto file = response.release_value(); | ||||
|  | @ -525,7 +525,7 @@ void HexEditorWidget::update_title() | |||
|     window()->set_title(builder.to_deprecated_string()); | ||||
| } | ||||
| 
 | ||||
| void HexEditorWidget::open_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file) | ||||
| void HexEditorWidget::open_file(String const& filename, NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     window()->set_modified(false); | ||||
|     m_editor->open_file(move(file)); | ||||
|  | @ -586,7 +586,7 @@ void HexEditorWidget::drop_event(GUI::DropEvent& event) | |||
|             return; | ||||
| 
 | ||||
|         // TODO: A drop event should be considered user consent for opening a file
 | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::Stream::OpenMode::Read); | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::File::OpenMode::Read); | ||||
|         if (response.is_error()) | ||||
|             return; | ||||
|         open_file(response.value().filename(), response.value().release_stream()); | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ class HexEditorWidget final : public GUI::Widget { | |||
|     C_OBJECT(HexEditorWidget) | ||||
| public: | ||||
|     virtual ~HexEditorWidget() override = default; | ||||
|     void open_file(String const& filename, NonnullOwnPtr<Core::Stream::File>); | ||||
|     void open_file(String const& filename, NonnullOwnPtr<Core::File>); | ||||
|     void initialize_menubar(GUI::Window&); | ||||
|     bool request_close(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
| 
 | ||||
|     if (arguments.argc > 1) { | ||||
|         // FIXME: Using `try_request_file_read_only_approved` doesn't work here since the file stored in the editor is only readable.
 | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window, arguments.strings[1], Core::Stream::OpenMode::ReadWrite); | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window, arguments.strings[1], Core::File::OpenMode::ReadWrite); | ||||
|         if (response.is_error()) | ||||
|             return 1; | ||||
|         hex_editor_widget->open_file(response.value().filename(), response.value().release_stream()); | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
| 
 | ||||
| #include "KeyboardMapperWidget.h" | ||||
| #include "KeyPositions.h" | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibGUI/BoxLayout.h> | ||||
| #include <LibGUI/InputBox.h> | ||||
|  | @ -191,7 +192,7 @@ ErrorOr<void> KeyboardMapperWidget::save_to_file(StringView filename) | |||
| 
 | ||||
|     // Write to file.
 | ||||
|     DeprecatedString file_content = map_json.to_deprecated_string(); | ||||
|     auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Write)); | ||||
|     auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write)); | ||||
|     TRY(file->write(file_content.bytes())); | ||||
|     file->close(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -62,7 +62,7 @@ NetworkSettingsWidget::NetworkSettingsWidget() | |||
| 
 | ||||
|     auto config_file = Core::ConfigFile::open_for_system("Network").release_value_but_fixme_should_propagate_errors(); | ||||
| 
 | ||||
|     auto proc_net_adapters_file = Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); | ||||
|     auto proc_net_adapters_file = Core::File::open("/sys/kernel/net/adapters"sv, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); | ||||
|     auto data = proc_net_adapters_file->read_until_eof().release_value_but_fixme_should_propagate_errors(); | ||||
|     JsonParser parser(data); | ||||
|     JsonValue proc_net_adapters_json = parser.parse().release_value_but_fixme_should_propagate_errors(); | ||||
|  |  | |||
|  | @ -348,7 +348,7 @@ void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar) | |||
|     m_show_images->on_checked = [&](auto checked) { m_viewer->set_show_images(checked); }; | ||||
| } | ||||
| 
 | ||||
| void PDFViewerWidget::open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file) | ||||
| void PDFViewerWidget::open_file(StringView path, NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     auto maybe_error = try_open_file(path, move(file)); | ||||
|     if (maybe_error.is_error()) { | ||||
|  | @ -359,7 +359,7 @@ void PDFViewerWidget::open_file(StringView path, NonnullOwnPtr<Core::Stream::Fil | |||
|     } | ||||
| } | ||||
| 
 | ||||
| PDF::PDFErrorOr<void> PDFViewerWidget::try_open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file) | ||||
| PDF::PDFErrorOr<void> PDFViewerWidget::try_open_file(StringView path, NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     window()->set_title(DeprecatedString::formatted("{} - PDF Viewer", path)); | ||||
| 
 | ||||
|  |  | |||
|  | @ -26,13 +26,13 @@ public: | |||
|     ~PDFViewerWidget() override = default; | ||||
| 
 | ||||
|     void initialize_menubar(GUI::Window&); | ||||
|     void open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file); | ||||
|     void open_file(StringView path, NonnullOwnPtr<Core::File> file); | ||||
| 
 | ||||
| private: | ||||
|     PDFViewerWidget(); | ||||
| 
 | ||||
|     void initialize_toolbar(GUI::Toolbar&); | ||||
|     PDF::PDFErrorOr<void> try_open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file); | ||||
|     PDF::PDFErrorOr<void> try_open_file(StringView path, NonnullOwnPtr<Core::File> file); | ||||
| 
 | ||||
|     RefPtr<PDFViewer> m_viewer; | ||||
|     RefPtr<SidebarWidget> m_sidebar; | ||||
|  |  | |||
|  | @ -733,7 +733,7 @@ void ImageEditor::save_project() | |||
|         save_project_as(); | ||||
|         return; | ||||
|     } | ||||
|     auto response = FileSystemAccessClient::Client::the().request_file(window(), path(), Core::Stream::OpenMode::Truncate | Core::Stream::OpenMode::Write); | ||||
|     auto response = FileSystemAccessClient::Client::the().request_file(window(), path(), Core::File::OpenMode::Truncate | Core::File::OpenMode::Write); | ||||
|     if (response.is_error()) | ||||
|         return; | ||||
|     auto result = save_project_to_file(response.value().release_stream()); | ||||
|  | @ -760,7 +760,7 @@ void ImageEditor::save_project_as() | |||
|     set_unmodified(); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::Stream::File> file) const | ||||
| ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::File> file) const | ||||
| { | ||||
|     StringBuilder builder; | ||||
|     auto json = TRY(JsonObjectSerializer<>::try_create(builder)); | ||||
|  |  | |||
|  | @ -153,7 +153,7 @@ private: | |||
|     GUI::MouseEvent event_adjusted_for_layer(GUI::MouseEvent const&, Layer const&) const; | ||||
|     GUI::MouseEvent event_with_pan_and_scale_applied(GUI::MouseEvent const&) const; | ||||
| 
 | ||||
|     ErrorOr<void> save_project_to_file(NonnullOwnPtr<Core::Stream::File>) const; | ||||
|     ErrorOr<void> save_project_to_file(NonnullOwnPtr<Core::File>) const; | ||||
| 
 | ||||
|     int calculate_ruler_step_size() const; | ||||
|     Gfx::IntRect mouse_indicator_rect_x() const; | ||||
|  |  | |||
|  | @ -1288,7 +1288,7 @@ void MainWidget::drop_event(GUI::DropEvent& event) | |||
|         if (url.scheme() != "file") | ||||
|             continue; | ||||
| 
 | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), url.path(), Core::Stream::OpenMode::Read); | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), url.path(), Core::File::OpenMode::Read); | ||||
|         if (response.is_error()) | ||||
|             return; | ||||
|         open_image(response.release_value()); | ||||
|  |  | |||
|  | @ -224,11 +224,11 @@ Vector<Color> PaletteWidget::colors() | |||
|     return colors; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::Stream::File> file) | ||||
| ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     Vector<Color> palette; | ||||
|     Array<u8, PAGE_SIZE> buffer; | ||||
|     auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file))); | ||||
|     auto buffered_file = TRY(Core::BufferedFile::create(move(file))); | ||||
| 
 | ||||
|     while (TRY(buffered_file->can_read_line())) { | ||||
|         auto line = TRY(buffered_file->read_line(buffer)); | ||||
|  | @ -252,11 +252,11 @@ ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::Stre | |||
| 
 | ||||
| ErrorOr<Vector<Color>> PaletteWidget::load_palette_path(DeprecatedString const& file_path) | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(file_path, Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open(file_path, Core::File::OpenMode::Read)); | ||||
|     return load_palette_file(move(file)); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> PaletteWidget::save_palette_file(Vector<Color> palette, NonnullOwnPtr<Core::Stream::File> file) | ||||
| ErrorOr<void> PaletteWidget::save_palette_file(Vector<Color> palette, NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     for (auto& color : palette) { | ||||
|         TRY(file->write_entire_buffer(color.to_deprecated_string_without_alpha().bytes())); | ||||
|  |  | |||
|  | @ -31,9 +31,9 @@ public: | |||
| 
 | ||||
|     Vector<Color> colors(); | ||||
| 
 | ||||
|     static ErrorOr<Vector<Color>> load_palette_file(NonnullOwnPtr<Core::Stream::File>); | ||||
|     static ErrorOr<Vector<Color>> load_palette_file(NonnullOwnPtr<Core::File>); | ||||
|     static ErrorOr<Vector<Color>> load_palette_path(DeprecatedString const&); | ||||
|     static ErrorOr<void> save_palette_file(Vector<Color>, NonnullOwnPtr<Core::Stream::File>); | ||||
|     static ErrorOr<void> save_palette_file(Vector<Color>, NonnullOwnPtr<Core::File>); | ||||
| 
 | ||||
|     static Vector<Color> fallback_colors(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ | |||
| 
 | ||||
| namespace PixelPaint { | ||||
| 
 | ||||
| ErrorOr<void> ProjectLoader::load_from_file(NonnullOwnPtr<Core::Stream::File> file) | ||||
| ErrorOr<void> ProjectLoader::load_from_file(NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     auto contents = TRY(file->read_until_eof()); | ||||
| 
 | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ public: | |||
|     ProjectLoader() = default; | ||||
|     ~ProjectLoader() = default; | ||||
| 
 | ||||
|     ErrorOr<void> load_from_file(NonnullOwnPtr<Core::Stream::File>); | ||||
|     ErrorOr<void> load_from_file(NonnullOwnPtr<Core::File>); | ||||
| 
 | ||||
|     bool is_raw_image() const { return m_is_raw_image; } | ||||
|     bool has_image() const { return !m_image.is_null(); } | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ | |||
| 
 | ||||
| #include "Presentation.h" | ||||
| #include <AK/JsonObject.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibGUI/Window.h> | ||||
| #include <errno_codes.h> | ||||
|  | @ -79,7 +80,7 @@ ErrorOr<NonnullOwnPtr<Presentation>> Presentation::load_from_file(StringView fil | |||
| { | ||||
|     if (file_name.is_empty()) | ||||
|         return ENOENT; | ||||
|     auto file = TRY(Core::Stream::File::open_file_or_standard_stream(file_name, Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open_file_or_standard_stream(file_name, Core::File::OpenMode::Read)); | ||||
|     auto contents = TRY(file->read_until_eof()); | ||||
|     auto content_string = StringView { contents }; | ||||
|     auto json = TRY(JsonValue::from_string(content_string)); | ||||
|  |  | |||
|  | @ -170,8 +170,8 @@ DeprecatedString RunWindow::history_file_path() | |||
| ErrorOr<void> RunWindow::load_history() | ||||
| { | ||||
|     m_path_history.clear(); | ||||
|     auto file = TRY(Core::Stream::File::open(history_file_path(), Core::Stream::OpenMode::Read)); | ||||
|     auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file))); | ||||
|     auto file = TRY(Core::File::open(history_file_path(), Core::File::OpenMode::Read)); | ||||
|     auto buffered_file = TRY(Core::BufferedFile::create(move(file))); | ||||
|     Array<u8, PAGE_SIZE> line_buffer; | ||||
| 
 | ||||
|     while (!buffered_file->is_eof()) { | ||||
|  | @ -184,7 +184,7 @@ ErrorOr<void> RunWindow::load_history() | |||
| 
 | ||||
| ErrorOr<void> RunWindow::save_history() | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(history_file_path(), Core::Stream::OpenMode::Write)); | ||||
|     auto file = TRY(Core::File::open(history_file_path(), Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     // Write the first 25 items of history
 | ||||
|     for (int i = 0; i < min(static_cast<int>(m_path_history.size()), 25); i++) | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ | |||
| #include <AK/RefPtr.h> | ||||
| #include <AK/ScopeGuard.h> | ||||
| #include <AK/Utf8View.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| 
 | ||||
| M3UParser::M3UParser() | ||||
|  | @ -17,7 +18,7 @@ M3UParser::M3UParser() | |||
| 
 | ||||
| NonnullOwnPtr<M3UParser> M3UParser::from_file(StringView path) | ||||
| { | ||||
|     auto file_result = Core::Stream::File::open(path, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); | ||||
|     auto file_result = Core::File::open(path, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); | ||||
|     auto contents = file_result->read_until_eof().release_value_but_fixme_should_propagate_errors(); | ||||
|     auto use_utf8 = path.ends_with(".m3u8"sv, CaseSensitivity::CaseInsensitive); | ||||
|     return from_memory(DeprecatedString { contents, NoChomp }, use_utf8); | ||||
|  |  | |||
|  | @ -375,7 +375,7 @@ void TreeMapWidget::recalculate_path_for_new_tree() | |||
| static ErrorOr<void> fill_mounts(Vector<MountInfo>& output) | ||||
| { | ||||
|     // Output info about currently mounted filesystems.
 | ||||
|     auto file = TRY(Core::Stream::File::open("/sys/kernel/df"sv, Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open("/sys/kernel/df"sv, Core::File::OpenMode::Read)); | ||||
| 
 | ||||
|     auto content = TRY(file->read_until_eof()); | ||||
|     auto json = TRY(JsonValue::from_string(content)); | ||||
|  |  | |||
|  | @ -178,7 +178,7 @@ void CSVExportDialogPage::update_preview() | |||
|         m_data_preview_text_editor->set_text(DeprecatedString::formatted("Cannot update preview: {}", maybe_error.error())); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::Stream::File& file, DeprecatedString filename, Workbook& workbook) | ||||
| ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::File& file, DeprecatedString filename, Workbook& workbook) | ||||
| { | ||||
|     auto wizard = GUI::WizardDialog::construct(GUI::Application::the()->active_window()); | ||||
|     wizard->set_title("File Export Wizard"); | ||||
|  |  | |||
|  | @ -58,7 +58,7 @@ private: | |||
| }; | ||||
| 
 | ||||
| struct ExportDialog { | ||||
|     static ErrorOr<void> make_and_run_for(StringView mime, Core::Stream::File&, DeprecatedString filename, Workbook&); | ||||
|     static ErrorOr<void> make_and_run_for(StringView mime, Core::File&, DeprecatedString filename, Workbook&); | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -174,7 +174,7 @@ void CSVImportDialogPage::update_preview() | |||
|     m_data_preview_table_view->update(); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::Stream::File& file, Workbook& workbook) | ||||
| ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook) | ||||
| { | ||||
|     auto wizard = GUI::WizardDialog::construct(&parent); | ||||
|     wizard->set_title("File Import Wizard"); | ||||
|  |  | |||
|  | @ -55,7 +55,7 @@ private: | |||
| }; | ||||
| 
 | ||||
| struct ImportDialog { | ||||
|     static ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::Stream::File& file, Workbook&); | ||||
|     static ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&); | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -147,7 +147,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe | |||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), current_filename(), Core::Stream::OpenMode::Write); | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), current_filename(), Core::File::OpenMode::Write); | ||||
|         if (response.is_error()) | ||||
|             return; | ||||
|         save(response.value().filename(), response.value().stream()); | ||||
|  | @ -493,7 +493,7 @@ void SpreadsheetWidget::change_cell_static_color_format(Spreadsheet::FormatType | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void SpreadsheetWidget::save(String const& filename, Core::Stream::File& file) | ||||
| void SpreadsheetWidget::save(String const& filename, Core::File& file) | ||||
| { | ||||
|     auto result = m_workbook->write_to_file(filename, file); | ||||
|     if (result.is_error()) { | ||||
|  | @ -504,7 +504,7 @@ void SpreadsheetWidget::save(String const& filename, Core::Stream::File& file) | |||
|     window()->set_modified(false); | ||||
| } | ||||
| 
 | ||||
| void SpreadsheetWidget::load_file(String const& filename, Core::Stream::File& file) | ||||
| void SpreadsheetWidget::load_file(String const& filename, Core::File& file) | ||||
| { | ||||
|     auto result = m_workbook->open_file(filename, file); | ||||
|     if (result.is_error()) { | ||||
|  | @ -523,7 +523,7 @@ void SpreadsheetWidget::load_file(String const& filename, Core::Stream::File& fi | |||
|     update_window_title(); | ||||
| } | ||||
| 
 | ||||
| void SpreadsheetWidget::import_sheets(String const& filename, Core::Stream::File& file) | ||||
| void SpreadsheetWidget::import_sheets(String const& filename, Core::File& file) | ||||
| { | ||||
|     auto result = m_workbook->import_file(filename, file); | ||||
|     if (result.is_error()) { | ||||
|  |  | |||
|  | @ -24,9 +24,9 @@ class SpreadsheetWidget final | |||
| public: | ||||
|     virtual ~SpreadsheetWidget() override = default; | ||||
| 
 | ||||
|     void save(String const& filename, Core::Stream::File&); | ||||
|     void load_file(String const& filename, Core::Stream::File&); | ||||
|     void import_sheets(String const& filename, Core::Stream::File&); | ||||
|     void save(String const& filename, Core::File&); | ||||
|     void load_file(String const& filename, Core::File&); | ||||
|     void import_sheets(String const& filename, Core::File&); | ||||
|     bool request_close(); | ||||
|     void add_sheet(); | ||||
|     void add_sheet(NonnullRefPtr<Sheet>&&); | ||||
|  |  | |||
|  | @ -50,7 +50,7 @@ bool Workbook::set_filename(DeprecatedString const& filename) | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void, DeprecatedString> Workbook::open_file(String const& filename, Core::Stream::File& file) | ||||
| ErrorOr<void, DeprecatedString> Workbook::open_file(String const& filename, Core::File& file) | ||||
| { | ||||
|     auto mime = Core::guess_mime_type_based_on_filename(filename); | ||||
| 
 | ||||
|  | @ -62,7 +62,7 @@ ErrorOr<void, DeprecatedString> Workbook::open_file(String const& filename, Core | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> Workbook::write_to_file(String const& filename, Core::Stream::File& stream) | ||||
| ErrorOr<void> Workbook::write_to_file(String const& filename, Core::File& stream) | ||||
| { | ||||
|     auto mime = Core::guess_mime_type_based_on_filename(filename); | ||||
| 
 | ||||
|  | @ -74,7 +74,7 @@ ErrorOr<void> Workbook::write_to_file(String const& filename, Core::Stream::File | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<bool, DeprecatedString> Workbook::import_file(String const& filename, Core::Stream::File& file) | ||||
| ErrorOr<bool, DeprecatedString> Workbook::import_file(String const& filename, Core::File& file) | ||||
| { | ||||
|     auto mime = Core::guess_mime_type_based_on_filename(filename); | ||||
| 
 | ||||
|  |  | |||
|  | @ -16,10 +16,10 @@ class Workbook { | |||
| public: | ||||
|     Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_window); | ||||
| 
 | ||||
|     ErrorOr<void, DeprecatedString> open_file(String const& filename, Core::Stream::File&); | ||||
|     ErrorOr<void> write_to_file(String const& filename, Core::Stream::File&); | ||||
|     ErrorOr<void, DeprecatedString> open_file(String const& filename, Core::File&); | ||||
|     ErrorOr<void> write_to_file(String const& filename, Core::File&); | ||||
| 
 | ||||
|     ErrorOr<bool, DeprecatedString> import_file(String const& filename, Core::Stream::File&); | ||||
|     ErrorOr<bool, DeprecatedString> import_file(String const& filename, Core::File&); | ||||
| 
 | ||||
|     DeprecatedString const& current_filename() const { return m_current_filename; } | ||||
|     bool set_filename(DeprecatedString const& filename); | ||||
|  |  | |||
|  | @ -410,7 +410,7 @@ Vector<GUI::ModelIndex> ProcessModel::matches(StringView searching, unsigned fla | |||
| 
 | ||||
| static ErrorOr<DeprecatedString> try_read_command_line(pid_t pid) | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/cmdline", pid), Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open(DeprecatedString::formatted("/proc/{}/cmdline", pid), Core::File::OpenMode::Read)); | ||||
|     auto data = TRY(file->read_until_eof()); | ||||
|     auto json = TRY(JsonValue::from_string(StringView { data.bytes() })); | ||||
|     auto array = json.as_array().values(); | ||||
|  |  | |||
|  | @ -303,7 +303,7 @@ MainWidget::MainWidget() | |||
|             m_save_as_action->activate(); | ||||
|             return; | ||||
|         } | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), m_path, Core::Stream::OpenMode::Truncate | Core::Stream::OpenMode::Write); | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), m_path, Core::File::OpenMode::Truncate | Core::File::OpenMode::Write); | ||||
|         if (response.is_error()) | ||||
|             return; | ||||
| 
 | ||||
|  | @ -746,7 +746,7 @@ void MainWidget::update_title() | |||
|     window()->set_title(builder.to_deprecated_string()); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> MainWidget::read_file(String const& filename, Core::Stream::File& file) | ||||
| ErrorOr<void> MainWidget::read_file(String const& filename, Core::File& file) | ||||
| { | ||||
|     m_editor->set_text(TRY(file.read_until_eof())); | ||||
|     set_path(filename); | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ class MainWidget final : public GUI::Widget { | |||
| 
 | ||||
| public: | ||||
|     virtual ~MainWidget() override = default; | ||||
|     ErrorOr<void> read_file(String const& filename, Core::Stream::File&); | ||||
|     ErrorOr<void> read_file(String const& filename, Core::File&); | ||||
|     void open_nonexistent_file(DeprecatedString const& path); | ||||
|     bool request_close(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -250,12 +250,12 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window) | |||
| 
 | ||||
|     m_save_action = GUI::CommonActions::make_save_action([&](auto&) { | ||||
|         if (m_path.has_value()) { | ||||
|             auto result = FileSystemAccessClient::Client::the().request_file(&window, *m_path, Core::Stream::OpenMode::ReadWrite | Core::Stream::OpenMode::Truncate); | ||||
|             auto result = FileSystemAccessClient::Client::the().request_file(&window, *m_path, Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate); | ||||
|             if (result.is_error()) | ||||
|                 return; | ||||
|             save_to_file(result.value().filename(), result.value().release_stream()); | ||||
|         } else { | ||||
|             auto result = FileSystemAccessClient::Client::the().save_file(&window, "Theme", "ini", Core::Stream::OpenMode::ReadWrite | Core::Stream::OpenMode::Truncate); | ||||
|             auto result = FileSystemAccessClient::Client::the().save_file(&window, "Theme", "ini", Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate); | ||||
|             if (result.is_error()) | ||||
|                 return; | ||||
|             save_to_file(result.value().filename(), result.value().release_stream()); | ||||
|  | @ -264,7 +264,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window) | |||
|     TRY(file_menu->try_add_action(*m_save_action)); | ||||
| 
 | ||||
|     TRY(file_menu->try_add_action(GUI::CommonActions::make_save_as_action([&](auto&) { | ||||
|         auto result = FileSystemAccessClient::Client::the().save_file(&window, "Theme", "ini", Core::Stream::OpenMode::ReadWrite | Core::Stream::OpenMode::Truncate); | ||||
|         auto result = FileSystemAccessClient::Client::the().save_file(&window, "Theme", "ini", Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate); | ||||
|         if (result.is_error()) | ||||
|             return; | ||||
|         save_to_file(result.value().filename(), result.value().release_stream()); | ||||
|  | @ -315,7 +315,7 @@ void MainWidget::set_path(DeprecatedString path) | |||
|     update_title(); | ||||
| } | ||||
| 
 | ||||
| void MainWidget::save_to_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file) | ||||
| void MainWidget::save_to_file(String const& filename, NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     auto theme = Core::ConfigFile::open(filename.to_deprecated_string(), move(file)).release_value_but_fixme_should_propagate_errors(); | ||||
| 
 | ||||
|  | @ -601,7 +601,7 @@ void MainWidget::show_path_picker_dialog(StringView property_display_name, GUI:: | |||
|     path_input.set_text(*result); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> MainWidget::load_from_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file) | ||||
| ErrorOr<void> MainWidget::load_from_file(String const& filename, NonnullOwnPtr<Core::File> file) | ||||
| { | ||||
|     auto config_file = TRY(Core::ConfigFile::open(filename.to_deprecated_string(), move(file))); | ||||
|     auto theme = TRY(Gfx::load_system_theme(config_file)); | ||||
|  | @ -669,7 +669,7 @@ void MainWidget::drop_event(GUI::DropEvent& event) | |||
|         if (request_close() == GUI::Window::CloseRequestDecision::StayOpen) | ||||
|             return; | ||||
| 
 | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::Stream::OpenMode::Read); | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::File::OpenMode::Read); | ||||
|         if (response.is_error()) | ||||
|             return; | ||||
| 
 | ||||
|  |  | |||
|  | @ -86,7 +86,7 @@ public: | |||
|     ErrorOr<void> initialize_menubar(GUI::Window&); | ||||
|     GUI::Window::CloseRequestDecision request_close(); | ||||
|     void update_title(); | ||||
|     ErrorOr<void> load_from_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file); | ||||
|     ErrorOr<void> load_from_file(String const& filename, NonnullOwnPtr<Core::File> file); | ||||
| 
 | ||||
| private: | ||||
|     explicit MainWidget(NonnullRefPtr<AlignmentModel>); | ||||
|  | @ -94,7 +94,7 @@ private: | |||
|     virtual void drag_enter_event(GUI::DragEvent&) override; | ||||
|     virtual void drop_event(GUI::DropEvent&) override; | ||||
| 
 | ||||
|     void save_to_file(String const& filename, NonnullOwnPtr<Core::Stream::File> file); | ||||
|     void save_to_file(String const& filename, NonnullOwnPtr<Core::File> file); | ||||
|     ErrorOr<Core::AnonymousBuffer> encode(); | ||||
|     void set_path(DeprecatedString); | ||||
| 
 | ||||
|  |  | |||
|  | @ -95,8 +95,8 @@ ErrorOr<void> WelcomeWidget::create_widgets() | |||
| ErrorOr<void> WelcomeWidget::open_and_parse_tips_file() | ||||
| { | ||||
|     auto path = TRY(String::formatted("{}/tips.txt", Core::StandardPaths::documents_directory())); | ||||
|     auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read)); | ||||
|     auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file))); | ||||
|     auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); | ||||
|     auto buffered_file = TRY(Core::BufferedFile::create(move(file))); | ||||
|     Array<u8, PAGE_SIZE> buffer; | ||||
| 
 | ||||
|     while (TRY(buffered_file->can_read_line())) { | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
|  */ | ||||
| 
 | ||||
| #include "CatDog.h" | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/ProcessStatisticsReader.h> | ||||
| #include <LibGUI/Painter.h> | ||||
| #include <LibGUI/Window.h> | ||||
|  | @ -55,7 +56,7 @@ ErrorOr<NonnullRefPtr<CatDog>> CatDog::create() | |||
| } | ||||
| 
 | ||||
| CatDog::CatDog() | ||||
|     : m_proc_all(MUST(Core::Stream::File::open("/sys/kernel/processes"sv, Core::Stream::OpenMode::Read))) | ||||
|     : m_proc_all(MUST(Core::File::open("/sys/kernel/processes"sv, Core::File::OpenMode::Read))) | ||||
| { | ||||
|     m_idle_sleep_timer.start(); | ||||
| } | ||||
|  |  | |||
|  | @ -74,7 +74,7 @@ private: | |||
|     Gfx::IntPoint m_mouse_offset {}; | ||||
|     Core::ElapsedTimer m_idle_sleep_timer; | ||||
| 
 | ||||
|     NonnullOwnPtr<Core::Stream::File> m_proc_all; | ||||
|     NonnullOwnPtr<Core::File> m_proc_all; | ||||
| 
 | ||||
|     State m_state { State::Roaming }; | ||||
|     State m_frame { State::Frame1 }; | ||||
|  |  | |||
|  | @ -157,7 +157,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|             save_as_action->activate(); | ||||
|             return; | ||||
|         } | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window, file_path, Core::Stream::OpenMode::Truncate | Core::Stream::OpenMode::Write); | ||||
|         auto response = FileSystemAccessClient::Client::the().request_file(window, file_path, Core::File::OpenMode::Truncate | Core::File::OpenMode::Write); | ||||
|         if (response.is_error()) | ||||
|             return; | ||||
| 
 | ||||
|  |  | |||
|  | @ -232,7 +232,7 @@ void Editor::show_documentation_tooltip_if_available(DeprecatedString const& hov | |||
|     } | ||||
| 
 | ||||
|     dbgln_if(EDITOR_DEBUG, "opening {}", it->value); | ||||
|     auto file_or_error = Core::Stream::File::open(it->value, Core::Stream::OpenMode::Read); | ||||
|     auto file_or_error = Core::File::open(it->value, Core::File::OpenMode::Read); | ||||
|     if (file_or_error.is_error()) { | ||||
|         dbgln("Failed to open {}, {}", it->value, file_or_error.error()); | ||||
|         return; | ||||
|  |  | |||
|  | @ -155,7 +155,7 @@ void GitWidget::set_view_diff_callback(ViewDiffCallback callback) | |||
| void GitWidget::show_diff(DeprecatedString const& file_path) | ||||
| { | ||||
|     if (!m_git_repo->is_tracked(file_path)) { | ||||
|         auto file = Core::Stream::File::open(file_path, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); | ||||
|         auto file = Core::File::open(file_path, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); | ||||
|         auto content = file->read_until_eof().release_value_but_fixme_should_propagate_errors(); | ||||
|         m_view_diff_callback("", Diff::generate_only_additions(content)); | ||||
|         return; | ||||
|  |  | |||
|  | @ -550,7 +550,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_file_action(Dep | |||
| 
 | ||||
|         filepath = DeprecatedString::formatted("{}{}", filepath, filename); | ||||
| 
 | ||||
|         auto file_or_error = Core::Stream::File::open(filepath, Core::Stream::OpenMode::Write | Core::Stream::OpenMode::MustBeNew); | ||||
|         auto file_or_error = Core::File::open(filepath, Core::File::OpenMode::Write | Core::File::OpenMode::MustBeNew); | ||||
|         if (file_or_error.is_error()) { | ||||
|             GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to create '{}': {}", filepath, file_or_error.error())); | ||||
|             return; | ||||
|  | @ -1791,7 +1791,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_open_project_config | |||
|             if (maybe_error.is_error() && maybe_error.error().code() != EEXIST) | ||||
|                 return maybe_error.release_error(); | ||||
| 
 | ||||
|             auto file = TRY(Core::Stream::File::open(absolute_config_file_path, Core::Stream::OpenMode::Write)); | ||||
|             auto file = TRY(Core::File::open(absolute_config_file_path, Core::File::OpenMode::Write)); | ||||
|             TRY(file->write_entire_buffer( | ||||
|                 "{\n" | ||||
|                 "    \"build_command\": \"your build command here\",\n" | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ | |||
| #include <AK/Debug.h> | ||||
| #include <AK/LexicalPath.h> | ||||
| #include <AK/NonnullRefPtr.h> | ||||
| #include <LibCore/File.h> | ||||
| 
 | ||||
| namespace LanguageServers { | ||||
| 
 | ||||
|  | @ -74,13 +75,13 @@ DeprecatedString FileDB::to_absolute_path(DeprecatedString const& filename) cons | |||
| 
 | ||||
| ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_filesystem(DeprecatedString const& filename) const | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(to_absolute_path(filename), Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open(to_absolute_path(filename), Core::File::OpenMode::Read)); | ||||
|     return create_from_file(move(file)); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_fd(int fd) const | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::adopt_fd(fd, Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::adopt_fd(fd, Core::File::OpenMode::Read)); | ||||
|     return create_from_file(move(file)); | ||||
| } | ||||
| 
 | ||||
|  | @ -101,7 +102,7 @@ public: | |||
| }; | ||||
| static DefaultDocumentClient s_default_document_client; | ||||
| 
 | ||||
| ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_file(NonnullOwnPtr<Core::Stream::File> file) const | ||||
| ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_file(NonnullOwnPtr<Core::File> file) const | ||||
| { | ||||
|     auto content = TRY(file->read_until_eof()); | ||||
|     auto document = GUI::TextDocument::create(&s_default_document_client); | ||||
|  |  | |||
|  | @ -34,7 +34,7 @@ public: | |||
| private: | ||||
|     ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_filesystem(DeprecatedString const& filename) const; | ||||
|     ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_fd(int fd) const; | ||||
|     ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_file(NonnullOwnPtr<Core::Stream::File>) const; | ||||
|     ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_file(NonnullOwnPtr<Core::File>) const; | ||||
|     static RefPtr<GUI::TextDocument> create_with_content(DeprecatedString const&); | ||||
| 
 | ||||
| private: | ||||
|  |  | |||
|  | @ -112,7 +112,7 @@ ErrorOr<void> ProjectBuilder::build_serenity_component() | |||
| 
 | ||||
| ErrorOr<DeprecatedString> ProjectBuilder::component_name(StringView cmake_file_path) | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(cmake_file_path, Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Read)); | ||||
|     auto content = TRY(file->read_until_eof()); | ||||
| 
 | ||||
|     static Regex<ECMA262> const component_name(R"~~~(serenity_component\([\s]*(\w+)[\s\S]*\))~~~"); | ||||
|  | @ -135,7 +135,7 @@ ErrorOr<void> ProjectBuilder::initialize_build_directory() | |||
|     if (Core::DeprecatedFile::exists(cmake_file_path)) | ||||
|         MUST(Core::DeprecatedFile::remove(cmake_file_path, Core::DeprecatedFile::RecursionMode::Disallowed)); | ||||
| 
 | ||||
|     auto cmake_file = TRY(Core::Stream::File::open(cmake_file_path, Core::Stream::OpenMode::Write)); | ||||
|     auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Write)); | ||||
|     TRY(cmake_file->write_entire_buffer(generate_cmake_file_content().bytes())); | ||||
| 
 | ||||
|     TRY(m_terminal->run_command(DeprecatedString::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}" | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
| 
 | ||||
| #include "ProjectConfig.h" | ||||
| #include <AK/NonnullOwnPtr.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| 
 | ||||
| namespace HackStudio { | ||||
|  | @ -17,7 +18,7 @@ ProjectConfig::ProjectConfig(JsonObject config) | |||
| 
 | ||||
| ErrorOr<NonnullOwnPtr<ProjectConfig>> ProjectConfig::try_load_project_config(DeprecatedString 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_contents = TRY(file->read_until_eof()); | ||||
| 
 | ||||
|     auto json = TRY(JsonValue::from_string(file_contents)); | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
|  */ | ||||
| 
 | ||||
| #include "ProjectFile.h" | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| 
 | ||||
| namespace HackStudio { | ||||
|  | @ -54,7 +55,7 @@ void ProjectFile::create_document_if_needed() const | |||
|         return; | ||||
| 
 | ||||
|     m_document = CodeDocument::create(m_name); | ||||
|     auto file_or_error = Core::Stream::File::open(m_name, Core::Stream::OpenMode::Read); | ||||
|     auto file_or_error = Core::File::open(m_name, Core::File::OpenMode::Read); | ||||
|     if (file_or_error.is_error()) { | ||||
|         warnln("Couldn't open '{}': {}", m_name, file_or_error.error()); | ||||
|         // This is okay though, we'll just go with an empty document and create the file when saving.
 | ||||
|  |  | |||
|  | @ -236,7 +236,7 @@ OwnPtr<Debug::DebugInfo> g_kernel_debug_info; | |||
| 
 | ||||
| ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView 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 json = JsonValue::from_string(TRY(file->read_until_eof())); | ||||
|     if (json.is_error() || !json.value().is_object()) | ||||
|  |  | |||
|  | @ -29,8 +29,8 @@ public: | |||
|         DeprecatedString source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly); | ||||
| 
 | ||||
|         auto try_read_lines = [&]() -> ErrorOr<void> { | ||||
|             auto unbuffered_file = TRY(Core::Stream::File::open(source_file_name, Core::Stream::OpenMode::Read)); | ||||
|             auto file = TRY(Core::Stream::BufferedFile::create(move(unbuffered_file))); | ||||
|             auto unbuffered_file = TRY(Core::File::open(source_file_name, Core::File::OpenMode::Read)); | ||||
|             auto file = TRY(Core::BufferedFile::create(move(unbuffered_file))); | ||||
| 
 | ||||
|             Array<u8, 1024> buffer; | ||||
|             while (!file->is_eof()) | ||||
|  |  | |||
|  | @ -29,7 +29,7 @@ void ScriptEditor::new_script_with_temp_name(DeprecatedString name) | |||
| 
 | ||||
| ErrorOr<void> ScriptEditor::open_script_from_file(LexicalPath const& file_path) | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(file_path.string(), Core::Stream::OpenMode::Read)); | ||||
|     auto file = TRY(Core::File::open(file_path.string(), Core::File::OpenMode::Read)); | ||||
|     auto buffer = TRY(file->read_until_eof()); | ||||
| 
 | ||||
|     set_text({ buffer.bytes() }); | ||||
|  | @ -40,7 +40,7 @@ ErrorOr<void> ScriptEditor::open_script_from_file(LexicalPath const& file_path) | |||
| 
 | ||||
| static ErrorOr<void> save_text_to_file(StringView filename, DeprecatedString text) | ||||
| { | ||||
|     auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Write)); | ||||
|     auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write)); | ||||
| 
 | ||||
|     if (!text.is_empty()) | ||||
|         TRY(file->write_entire_buffer(text.bytes())); | ||||
|  |  | |||
|  | @ -61,7 +61,7 @@ int main(int argc, char** argv, char** env) | |||
|     OwnPtr<Vector<int>> profile_string_id_map; | ||||
| 
 | ||||
|     if (dump_profile) { | ||||
|         auto profile_stream_or_error = Core::Stream::File::open(profile_dump_path, Core::Stream::OpenMode::Write); | ||||
|         auto profile_stream_or_error = Core::File::open(profile_dump_path, Core::File::OpenMode::Write); | ||||
|         if (profile_stream_or_error.is_error()) { | ||||
|             warnln("Failed to open '{}' for writing: {}", profile_dump_path, profile_stream_or_error.error()); | ||||
|             return 1; | ||||
|  |  | |||
|  | @ -10,6 +10,7 @@ | |||
| #include <AK/Random.h> | ||||
| #include <AK/String.h> | ||||
| #include <LibCore/DateTime.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibCore/Stream.h> | ||||
| #include <LibGUI/MessageBox.h> | ||||
| #include <LibGUI/Painter.h> | ||||
|  | @ -532,7 +533,7 @@ DeprecatedString ChessWidget::get_fen() const | |||
|     return m_playback ? m_board_playback.to_fen() : m_board.to_fen(); | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> ChessWidget::import_pgn(Core::Stream::File& file) | ||||
| ErrorOr<void> ChessWidget::import_pgn(Core::File& file) | ||||
| { | ||||
|     m_board = Chess::Board(); | ||||
| 
 | ||||
|  | @ -629,7 +630,7 @@ ErrorOr<void> ChessWidget::import_pgn(Core::Stream::File& file) | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> ChessWidget::export_pgn(Core::Stream::File& file) const | ||||
| ErrorOr<void> ChessWidget::export_pgn(Core::File& file) const | ||||
| { | ||||
|     // Tag Pair Section
 | ||||
|     TRY(file.write("[Event \"Casual Game\"]\n"sv.bytes())); | ||||
|  |  | |||
|  | @ -54,8 +54,8 @@ public: | |||
|     void set_show_available_moves(bool e) { m_show_available_moves = e; } | ||||
| 
 | ||||
|     DeprecatedString get_fen() const; | ||||
|     ErrorOr<void> import_pgn(Core::Stream::File&); | ||||
|     ErrorOr<void> export_pgn(Core::Stream::File&) const; | ||||
|     ErrorOr<void> import_pgn(Core::File&); | ||||
|     ErrorOr<void> export_pgn(Core::File&) const; | ||||
| 
 | ||||
|     int resign(); | ||||
|     void flip_board(); | ||||
|  |  | |||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Tim Schumacher
						Tim Schumacher