1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:14:58 +00:00

Utilities: Port cpp utilities to Core::Stream

This commit is contained in:
Sam Atkins 2022-09-14 11:24:13 +01:00 committed by Linus Groh
parent 39a4f1560b
commit 05c3b48e63
3 changed files with 20 additions and 30 deletions

View file

@ -1,27 +1,24 @@
/*
* Copyright (c) 2021, the SerenityOS developers.
* Copyright (c) 2021-2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Try.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCpp/Lexer.h>
#include <LibMain/Main.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
Core::ArgsParser args_parser;
char const* path = nullptr;
StringView path;
args_parser.add_positional_argument(path, "Cpp File", "cpp-file", Core::ArgsParser::Required::Yes);
args_parser.parse(arguments);
auto file = Core::File::construct(path);
if (!file->open(Core::OpenMode::ReadOnly)) {
warnln("Failed to open {}: {}", path, file->error_string());
exit(1);
}
auto content = file->read_all();
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
auto content = TRY(file->read_all());
StringView content_view(content);
Cpp::Lexer lexer(content);