diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2022-04-30 21:13:17 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-05-02 22:18:27 +0200 |
commit | ec1f5fd20fd27653abb9fd3023db34881730da3a (patch) | |
tree | 98813f9af0d9f0bfdf8dac42c390071d18d2936c | |
parent | 8ae492ba4d01da4dad4685f5b5e0fd3f09b03d0e (diff) | |
download | serenity-ec1f5fd20fd27653abb9fd3023db34881730da3a.zip |
base64: Use Core::File standard_input() standard_output()
-rw-r--r-- | Userland/Utilities/base64.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/Userland/Utilities/base64.cpp b/Userland/Utilities/base64.cpp index 8d65d39d70..28e521644f 100644 --- a/Userland/Utilities/base64.cpp +++ b/Userland/Utilities/base64.cpp @@ -4,16 +4,12 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <AK/Assertions.h> #include <AK/Base64.h> -#include <AK/ByteBuffer.h> #include <LibCore/ArgsParser.h> #include <LibCore/File.h> #include <LibCore/System.h> #include <LibMain/Main.h> -#include <stdio.h> #include <string.h> -#include <unistd.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { @@ -29,13 +25,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) ByteBuffer buffer; if (filepath == nullptr || strcmp(filepath, "-") == 0) { - auto file = Core::File::construct(); - bool success = file->open( - STDIN_FILENO, - Core::OpenMode::ReadOnly, - Core::File::ShouldCloseFileDescriptor::Yes); - VERIFY(success); - buffer = file->read_all(); + buffer = Core::File::standard_input()->read_all(); } else { auto result = Core::File::open(filepath, Core::OpenMode::ReadOnly); VERIFY(!result.is_error()); @@ -47,7 +37,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (decode) { auto decoded = TRY(decode_base64(StringView(buffer))); - fwrite(decoded.data(), sizeof(u8), decoded.size(), stdout); + Core::File::standard_output()->write(decoded.data(), decoded.size()); return 0; } |