summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/tar.cpp11
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> {