summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-03-10 13:16:56 +0000
committerAndreas Kling <kling@serenityos.org>2023-04-22 07:17:08 +0200
commit684af3d4d0b1941acb40479f089a666563714ab4 (patch)
treee32c5f68f21ca3a745ad848de6c1db8ab6df5932 /Userland/Utilities
parent0f95ff64edf782e21cbd8bef7609b54238330c11 (diff)
downloadserenity-684af3d4d0b1941acb40479f089a666563714ab4.zip
cmp: Use Core::File::open_file_or_standard_stream()
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/cmp.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/Userland/Utilities/cmp.cpp b/Userland/Utilities/cmp.cpp
index 0ceea7f6e1..d1433cbba8 100644
--- a/Userland/Utilities/cmp.cpp
+++ b/Userland/Utilities/cmp.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -8,17 +8,11 @@
#include <LibCore/File.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
-#include <unistd.h>
static ErrorOr<NonnullOwnPtr<Core::BufferedFile>> open_file_or_stdin(DeprecatedString const& filename)
{
- OwnPtr<Core::File> 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<int> serenity_main(Main::Arguments arguments)