diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-03-14 02:59:11 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-21 10:25:13 +0100 |
commit | 16cb127c0bea5b22fda01fd947205d55e8834533 (patch) | |
tree | 26bac757ddcc1622dab785f6c133a3969bf9060b | |
parent | a61c120b3fc0259627f22d5415402200f1eaf6e0 (diff) | |
download | serenity-16cb127c0bea5b22fda01fd947205d55e8834533.zip |
tar: Add partial support for XZ-compressed archives :^)
-rw-r--r-- | Userland/Utilities/tar.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp index 9b891d338f..44069aa925 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -11,6 +11,7 @@ #include <LibArchive/TarStream.h> #include <LibCompress/Gzip.h> #include <LibCompress/Lzma.h> +#include <LibCompress/Xz.h> #include <LibCore/ArgsParser.h> #include <LibCore/DeprecatedFile.h> #include <LibCore/DirIterator.h> @@ -32,6 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool verbose = false; bool gzip = false; bool lzma = false; + bool xz = false; bool no_auto_compress = false; StringView archive_file; bool dereference; @@ -45,6 +47,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_option(verbose, "Print paths", "verbose", 'v'); args_parser.add_option(gzip, "Compress or decompress file using gzip", "gzip", 'z'); args_parser.add_option(lzma, "Compress or decompress file using lzma", "lzma", 0); + args_parser.add_option(xz, "Compress or decompress file using xz", "xz", 'J'); args_parser.add_option(no_auto_compress, "Do not use the archive suffix to select the compression algorithm", "no-auto-compress", 0); args_parser.add_option(directory, "Directory to extract to/create from", "directory", 'C', "DIRECTORY"); args_parser.add_option(archive_file, "Archive file", "file", 'f', "FILE"); @@ -62,6 +65,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) gzip = true; if (archive_file.ends_with(".lzma"sv)) lzma = true; + if (archive_file.ends_with(".xz"sv)) + xz = true; } if (list || extract) { @@ -76,6 +81,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (lzma) input_stream = TRY(Compress::LzmaDecompressor::create_from_container(move(input_stream))); + if (xz) + input_stream = TRY(Compress::XzDecompressor::create(move(input_stream))); + auto tar_stream = TRY(Archive::TarInputStream::construct(move(input_stream))); HashMap<DeprecatedString, DeprecatedString> global_overrides; @@ -227,6 +235,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (lzma) TODO(); + if (xz) + TODO(); + Archive::TarOutputStream tar_stream(move(output_stream)); auto add_file = [&](DeprecatedString path) -> ErrorOr<void> { |