mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:57:35 +00:00
Utilities: Add an xzcat
utility
This commit is contained in:
parent
9e990f7329
commit
a61c120b3f
2 changed files with 37 additions and 1 deletions
|
@ -8,7 +8,7 @@ list(APPEND REQUIRED_TARGETS
|
||||||
)
|
)
|
||||||
list(APPEND RECOMMENDED_TARGETS
|
list(APPEND RECOMMENDED_TARGETS
|
||||||
adjtime aplay abench asctl bt checksum chres cksum copy fortune gunzip gzip init install keymap lsirq lsof lspci lzcat man mknod mktemp
|
adjtime aplay abench asctl bt checksum chres cksum copy fortune gunzip gzip init install keymap lsirq lsof lspci lzcat man mknod mktemp
|
||||||
nc netstat notify ntpquery open passwd pls printf pro shot strings tar tt unzip wallpaper zip
|
nc netstat notify ntpquery open passwd pls printf pro shot strings tar tt unzip wallpaper xzcat zip
|
||||||
)
|
)
|
||||||
|
|
||||||
# FIXME: Support specifying component dependencies for utilities (e.g. WebSocket for telws)
|
# FIXME: Support specifying component dependencies for utilities (e.g. WebSocket for telws)
|
||||||
|
@ -138,6 +138,7 @@ target_link_libraries(wallpaper PRIVATE LibGfx LibGUI)
|
||||||
target_link_libraries(wasm PRIVATE LibWasm LibLine LibJS)
|
target_link_libraries(wasm PRIVATE LibWasm LibLine LibJS)
|
||||||
target_link_libraries(wsctl PRIVATE LibGUI LibIPC)
|
target_link_libraries(wsctl PRIVATE LibGUI LibIPC)
|
||||||
target_link_libraries(xml PRIVATE LibXML)
|
target_link_libraries(xml PRIVATE LibXML)
|
||||||
|
target_link_libraries(xzcat PRIVATE LibCompress)
|
||||||
target_link_libraries(zip PRIVATE LibArchive LibCompress LibCrypto)
|
target_link_libraries(zip PRIVATE LibArchive LibCompress LibCrypto)
|
||||||
|
|
||||||
# FIXME: Link this file into headless-browser without compiling it again.
|
# FIXME: Link this file into headless-browser without compiling it again.
|
||||||
|
|
35
Userland/Utilities/xzcat.cpp
Normal file
35
Userland/Utilities/xzcat.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Tim Schumacher <timschumi@gmx.de>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibCompress/Xz.h>
|
||||||
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/File.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
|
|
||||||
|
ErrorOr<int> 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 stream = TRY(Compress::XzDecompressor::create(move(file)));
|
||||||
|
|
||||||
|
// Arbitrarily chosen buffer size.
|
||||||
|
Array<u8, 4096> buffer;
|
||||||
|
while (!stream->is_eof()) {
|
||||||
|
auto slice = TRY(stream->read_some(buffer));
|
||||||
|
out("{:s}", slice);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue