From 684af3d4d0b1941acb40479f089a666563714ab4 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 10 Mar 2023 13:16:56 +0000 Subject: [PATCH] cmp: Use Core::File::open_file_or_standard_stream() --- Userland/Utilities/cmp.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Userland/Utilities/cmp.cpp b/Userland/Utilities/cmp.cpp index 0ceea7f6e13..d1433cbba8f 100644 --- a/Userland/Utilities/cmp.cpp +++ b/Userland/Utilities/cmp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Sam Atkins + * Copyright (c) 2022-2023, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ @@ -8,17 +8,11 @@ #include #include #include -#include static ErrorOr> open_file_or_stdin(DeprecatedString const& filename) { - OwnPtr file; - if (filename == "-") { - file = TRY(Core::File::adopt_fd(STDIN_FILENO, Core::File::OpenMode::Read)); - } else { - file = TRY(Core::File::open(filename, Core::File::OpenMode::Read)); - } - return TRY(Core::BufferedFile::create(file.release_nonnull())); + auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read)); + return TRY(Core::BufferedFile::create(move(file))); } ErrorOr serenity_main(Main::Arguments arguments)