mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
tar: Add partial support for XZ-compressed archives :^)
This commit is contained in:
parent
a61c120b3f
commit
16cb127c0b
1 changed files with 11 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <LibArchive/TarStream.h>
|
#include <LibArchive/TarStream.h>
|
||||||
#include <LibCompress/Gzip.h>
|
#include <LibCompress/Gzip.h>
|
||||||
#include <LibCompress/Lzma.h>
|
#include <LibCompress/Lzma.h>
|
||||||
|
#include <LibCompress/Xz.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/DeprecatedFile.h>
|
#include <LibCore/DeprecatedFile.h>
|
||||||
#include <LibCore/DirIterator.h>
|
#include <LibCore/DirIterator.h>
|
||||||
|
@ -32,6 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
bool gzip = false;
|
bool gzip = false;
|
||||||
bool lzma = false;
|
bool lzma = false;
|
||||||
|
bool xz = false;
|
||||||
bool no_auto_compress = false;
|
bool no_auto_compress = false;
|
||||||
StringView archive_file;
|
StringView archive_file;
|
||||||
bool dereference;
|
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(verbose, "Print paths", "verbose", 'v');
|
||||||
args_parser.add_option(gzip, "Compress or decompress file using gzip", "gzip", 'z');
|
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(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(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(directory, "Directory to extract to/create from", "directory", 'C', "DIRECTORY");
|
||||||
args_parser.add_option(archive_file, "Archive file", "file", 'f', "FILE");
|
args_parser.add_option(archive_file, "Archive file", "file", 'f', "FILE");
|
||||||
|
@ -62,6 +65,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
gzip = true;
|
gzip = true;
|
||||||
if (archive_file.ends_with(".lzma"sv))
|
if (archive_file.ends_with(".lzma"sv))
|
||||||
lzma = true;
|
lzma = true;
|
||||||
|
if (archive_file.ends_with(".xz"sv))
|
||||||
|
xz = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list || extract) {
|
if (list || extract) {
|
||||||
|
@ -76,6 +81,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
if (lzma)
|
if (lzma)
|
||||||
input_stream = TRY(Compress::LzmaDecompressor::create_from_container(move(input_stream)));
|
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)));
|
auto tar_stream = TRY(Archive::TarInputStream::construct(move(input_stream)));
|
||||||
|
|
||||||
HashMap<DeprecatedString, DeprecatedString> global_overrides;
|
HashMap<DeprecatedString, DeprecatedString> global_overrides;
|
||||||
|
@ -227,6 +235,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
if (lzma)
|
if (lzma)
|
||||||
TODO();
|
TODO();
|
||||||
|
|
||||||
|
if (xz)
|
||||||
|
TODO();
|
||||||
|
|
||||||
Archive::TarOutputStream tar_stream(move(output_stream));
|
Archive::TarOutputStream tar_stream(move(output_stream));
|
||||||
|
|
||||||
auto add_file = [&](DeprecatedString path) -> ErrorOr<void> {
|
auto add_file = [&](DeprecatedString path) -> ErrorOr<void> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue