diff options
author | Tim Schumacher <timschumi@gmx.de> | 2022-12-08 15:04:49 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-12-14 15:19:35 +0000 |
commit | 558fab2703cac636a181cc176d5ae63fd4c12296 (patch) | |
tree | b62324a70556ca325680289695b8f4cc04ca8e65 /Userland/Libraries/LibIDL | |
parent | 2577bb8416e2f59141e136812918fcde23f1f0a4 (diff) | |
download | serenity-558fab2703cac636a181cc176d5ae63fd4c12296.zip |
LibIDL: Use `Core::Stream` to read imports
Diffstat (limited to 'Userland/Libraries/LibIDL')
-rw-r--r-- | Userland/Libraries/LibIDL/IDLParser.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibIDL/IDLParser.cpp b/Userland/Libraries/LibIDL/IDLParser.cpp index 5fb0a95c05..dba2a2d870 100644 --- a/Userland/Libraries/LibIDL/IDLParser.cpp +++ b/Userland/Libraries/LibIDL/IDLParser.cpp @@ -12,6 +12,7 @@ #include <AK/LexicalPath.h> #include <AK/QuickSort.h> #include <LibCore/File.h> +#include <LibCore/Stream.h> [[noreturn]] static void report_parsing_error(StringView message, StringView filename, StringView input, size_t offset) { @@ -148,12 +149,14 @@ Optional<Interface&> Parser::resolve_import(auto path) report_parsing_error(DeprecatedString::formatted("Circular import detected: {}", include_path), filename, input, lexer.tell()); import_stack.set(real_path); - auto file_or_error = Core::File::open(real_path, Core::OpenMode::ReadOnly); + auto file_or_error = Core::Stream::File::open(real_path, Core::Stream::OpenMode::Read); if (file_or_error.is_error()) report_parsing_error(DeprecatedString::formatted("Failed to open {}: {}", real_path, file_or_error.error()), filename, input, lexer.tell()); - auto data = file_or_error.value()->read_all(); - auto& result = Parser(this, real_path, data, import_base_path).parse(); + auto data_or_error = file_or_error.value()->read_until_eof(); + if (data_or_error.is_error()) + report_parsing_error(DeprecatedString::formatted("Failed to read {}: {}", real_path, data_or_error.error()), filename, input, lexer.tell()); + auto& result = Parser(this, real_path, data_or_error.value(), import_base_path).parse(); import_stack.remove(real_path); top_level_resolved_imports().set(real_path, &result); |