/* * Copyright (c) 2023, Tim Schumacher * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include ErrorOr serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("rpath stdio")); StringView filename; Core::ArgsParser args_parser; args_parser.set_general_help("Decompress and print an XZ archive"); args_parser.add_positional_argument(filename, "File to decompress", "file"); args_parser.parse(arguments); auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read)); auto buffered_file = TRY(Core::InputBufferedFile::create(move(file))); auto stream = TRY(Compress::XzDecompressor::create(move(buffered_file))); // Arbitrarily chosen buffer size. Array buffer; while (!stream->is_eof()) { auto slice = TRY(stream->read_some(buffer)); out("{:s}", slice); } return 0; }