mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
cmp: Use Core::File::open_file_or_standard_stream()
This commit is contained in:
parent
0f95ff64ed
commit
684af3d4d0
Notes:
sideshowbarker
2024-07-17 03:59:29 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/684af3d4d0 Pull-request: https://github.com/SerenityOS/serenity/pull/17793 Reviewed-by: https://github.com/krkk Reviewed-by: https://github.com/trflynn89
1 changed files with 3 additions and 9 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue