diff --git a/Userland/Utilities/xml.cpp b/Userland/Utilities/xml.cpp index 866ec260eb..6f317f7752 100644 --- a/Userland/Utilities/xml.cpp +++ b/Userland/Utilities/xml.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -370,8 +371,8 @@ static auto parse(StringView contents) if (url.scheme() != "file") return Error::from_string_literal("NYI: Nonlocal entity"); - auto file = TRY(Core::File::open(url.path(), Core::OpenMode::ReadOnly)); - return String::copy(file->read_all()); + auto file = TRY(Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read)); + return String::copy(TRY(file->read_all())); }, }, }; @@ -439,7 +440,7 @@ static void do_run_tests(XML::Document& document) continue; } - auto file_result = Core::File::open(url.path(), Core::OpenMode::ReadOnly); + auto file_result = Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read); if (file_result.is_error()) { warnln("Read error for {}: {}", url.path(), file_result.error()); s_test_results.set(url.path(), TestResult::RunnerFailed); @@ -449,7 +450,12 @@ static void do_run_tests(XML::Document& document) warnln("Running test {}", url.path()); auto contents = file_result.value()->read_all(); - auto parser = parse(contents); + if (contents.is_error()) { + warnln("Read error for {}: {}", url.path(), contents.error()); + s_test_results.set(url.path(), TestResult::RunnerFailed); + continue; + } + auto parser = parse(contents.value()); auto doc_or_error = parser.parse(); if (doc_or_error.is_error()) { if (type == "invalid" || type == "error" || type == "not-wf") @@ -462,14 +468,19 @@ static void do_run_tests(XML::Document& document) auto out = suite.attributes.find("OUTPUT"); if (out != suite.attributes.end()) { auto out_path = LexicalPath::join(test_base_path, out->value).string(); - auto file_result = Core::File::open(out_path, Core::OpenMode::ReadOnly); + auto file_result = Core::Stream::File::open(out_path, Core::Stream::OpenMode::Read); if (file_result.is_error()) { warnln("Read error for {}: {}", out_path, file_result.error()); s_test_results.set(url.path(), TestResult::RunnerFailed); continue; } auto contents = file_result.value()->read_all(); - auto parser = parse(contents); + if (contents.is_error()) { + warnln("Read error for {}: {}", out_path, contents.error()); + s_test_results.set(url.path(), TestResult::RunnerFailed); + continue; + } + auto parser = parse(contents.value()); auto out_doc_or_error = parser.parse(); if (out_doc_or_error.is_error()) { warnln("Parse error for {}: {}", out_path, out_doc_or_error.error()); @@ -505,8 +516,8 @@ ErrorOr serenity_main(Main::Arguments arguments) parser.parse(arguments); s_path = Core::File::real_path_for(filename); - auto file = TRY(Core::File::open(s_path, Core::OpenMode::ReadOnly)); - auto contents = file->read_all(); + auto file = TRY(Core::Stream::File::open(s_path, Core::Stream::OpenMode::Read)); + auto contents = TRY(file->read_all()); auto xml_parser = parse(contents); auto result = xml_parser.parse();