diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-03-09 00:50:58 +0100 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2023-03-20 12:15:38 +0200 |
commit | df30fd623207101123e850221086232fb3c2c000 (patch) | |
tree | 1ab4d60d6172e21c3171754d44fdf8ae23bb9059 /Userland/Utilities/tar.cpp | |
parent | 391485cceff998afaabe31044542db30d970b1a5 (diff) | |
download | serenity-df30fd623207101123e850221086232fb3c2c000.zip |
tar: Add partial support for LZMA-compressed archives
Diffstat (limited to 'Userland/Utilities/tar.cpp')
-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 ae8b9352fc..9b891d338f 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -10,6 +10,7 @@ #include <AK/Vector.h> #include <LibArchive/TarStream.h> #include <LibCompress/Gzip.h> +#include <LibCompress/Lzma.h> #include <LibCore/ArgsParser.h> #include <LibCore/DeprecatedFile.h> #include <LibCore/DirIterator.h> @@ -30,6 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool list = false; bool verbose = false; bool gzip = false; + bool lzma = false; bool no_auto_compress = false; StringView archive_file; bool dereference; @@ -42,6 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_option(list, "List contents", "list", 't'); 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(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"); @@ -57,6 +60,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!no_auto_compress && !archive_file.is_empty()) { if (archive_file.ends_with(".gz"sv) || archive_file.ends_with(".tgz"sv)) gzip = true; + if (archive_file.ends_with(".lzma"sv)) + lzma = true; } if (list || extract) { @@ -68,6 +73,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (gzip) input_stream = make<Compress::GzipDecompressor>(move(input_stream)); + if (lzma) + input_stream = TRY(Compress::LzmaDecompressor::create_from_container(move(input_stream))); + auto tar_stream = TRY(Archive::TarInputStream::construct(move(input_stream))); HashMap<DeprecatedString, DeprecatedString> global_overrides; @@ -216,6 +224,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (gzip) output_stream = TRY(try_make<Compress::GzipCompressor>(move(output_stream))); + if (lzma) + TODO(); + Archive::TarOutputStream tar_stream(move(output_stream)); auto add_file = [&](DeprecatedString path) -> ErrorOr<void> { |