From 2228786329e462c07d5eadb4077ea2bac801782c Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 14 Sep 2022 12:59:23 +0100 Subject: [PATCH] gron: Port to Core::Stream --- Userland/Utilities/gron.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Userland/Utilities/gron.cpp b/Userland/Utilities/gron.cpp index a86494a605..deafb76935 100644 --- a/Userland/Utilities/gron.cpp +++ b/Userland/Utilities/gron.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,16 +41,11 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(path, "Input", "input", Core::ArgsParser::Required::No); args_parser.parse(arguments); - RefPtr file; - - if (path.is_null()) - file = Core::File::standard_input(); - else - file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly)); + auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read)); TRY(Core::System::pledge("stdio")); - auto file_contents = file->read_all(); + auto file_contents = TRY(file->read_all()); auto json = TRY(JsonValue::from_string(file_contents)); if (use_color) {