diff options
Diffstat (limited to 'Userland/Utilities/base64.cpp')
-rw-r--r-- | Userland/Utilities/base64.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Userland/Utilities/base64.cpp b/Userland/Utilities/base64.cpp index 4d21b88199..dbcd0a1221 100644 --- a/Userland/Utilities/base64.cpp +++ b/Userland/Utilities/base64.cpp @@ -6,7 +6,7 @@ #include <AK/Base64.h> #include <LibCore/ArgsParser.h> -#include <LibCore/File.h> +#include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> @@ -22,19 +22,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(filepath, "", "file", Core::ArgsParser::Required::No); args_parser.parse(arguments); - ByteBuffer buffer; - if (filepath == nullptr || filepath == "-") { - buffer = Core::File::standard_input()->read_all(); - } else { - auto file = TRY(Core::File::open(filepath, Core::OpenMode::ReadOnly)); - buffer = file->read_all(); - } + auto file = TRY(Core::Stream::File::open_file_or_standard_stream(filepath, Core::Stream::OpenMode::Read)); + ByteBuffer buffer = TRY(file->read_all()); TRY(Core::System::pledge("stdio")); if (decode) { - auto decoded = TRY(decode_base64(StringView(buffer))); - Core::File::standard_output()->write(decoded.data(), decoded.size()); + auto decoded = TRY(decode_base64(buffer)); + out("{}", StringView(decoded.bytes())); return 0; } |