[file-roller] added support for lz4 compressed tar archives
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] added support for lz4 compressed tar archives
- Date: Wed, 17 Aug 2016 07:20:48 +0000 (UTC)
commit 95caf15ee1a7e42394a09557c5050ce7ef92083b
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Aug 17 09:01:53 2016 +0200
added support for lz4 compressed tar archives
[bug #770016]
src/fr-command-tar.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-
src/fr-init.c | 3 ++
2 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index 9e47b31..5a25d48 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -202,6 +202,9 @@ add_compress_arg (FrCommand *comm)
else if (_g_mime_type_matches (archive->mime_type, "application/x-lrzip-compressed-tar"))
fr_process_add_arg (comm->process, "--use-compress-program=lrzip");
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-lz4-compressed-tar"))
+ fr_process_add_arg (comm->process, "--use-compress-program=lz4");
+
else if (_g_mime_type_matches (archive->mime_type, "application/x-lzip-compressed-tar"))
fr_process_add_arg (comm->process, "--use-compress-program=lzip");
@@ -576,6 +579,26 @@ fr_command_tar_recompress (FrCommand *comm)
new_name = g_strconcat (c_tar->uncomp_filename, ".lrz", NULL);
}
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-lz4-compressed-tar")) {
+ fr_process_begin_command (comm->process, "lz4");
+ fr_process_set_begin_func (comm->process, begin_func__recompress, comm);
+ switch (archive->compression) {
+ case FR_COMPRESSION_VERY_FAST:
+ fr_process_add_arg (comm->process, "-1"); break;
+ case FR_COMPRESSION_FAST:
+ fr_process_add_arg (comm->process, "-3"); break;
+ case FR_COMPRESSION_NORMAL:
+ fr_process_add_arg (comm->process, "-6"); break;
+ case FR_COMPRESSION_MAXIMUM:
+ fr_process_add_arg (comm->process, "-9"); break;
+ }
+ fr_process_add_arg (comm->process, "-f");
+ fr_process_add_arg (comm->process, "-z");
+ fr_process_add_arg (comm->process, c_tar->uncomp_filename);
+ new_name = g_strconcat (c_tar->uncomp_filename, ".lz4", NULL);
+ fr_process_add_arg (comm->process, new_name);
+ fr_process_end_command (comm->process);
+ }
else if (_g_mime_type_matches (archive->mime_type, "application/x-lzip-compressed-tar")) {
fr_process_begin_command (comm->process, "lzip");
fr_process_set_begin_func (comm->process, begin_func__recompress, comm);
@@ -794,6 +817,17 @@ get_uncompressed_name (FrCommandTar *c_tar,
else if (_g_filename_has_extension (e_filename, ".tar.lrz"))
new_name[l - 4] = 0;
}
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-lz4-compressed-tar")) {
+ /* X.tlz4 --> X.tar
+ * X.tar.lz4 --> X.tar */
+ if (_g_filename_has_extension (e_filename, ".tlz4")) {
+ new_name[l - 3] = 'a';
+ new_name[l - 2] = 'r';
+ new_name[l - 1] = '0';
+ }
+ else if (_g_filename_has_extension (e_filename, ".tar.lz4"))
+ new_name[l - 4] = 0;
+ }
else if (_g_mime_type_matches (archive->mime_type, "application/x-lzip-compressed-tar")) {
/* X.tlz --> X.tar
* X.tar.lz --> X.tar */
@@ -895,6 +929,8 @@ fr_command_tar_uncompress (FrCommand *comm)
else
tmp_name = g_strdup (comm->filename);
+ c_tar->uncomp_filename = get_uncompressed_name (c_tar, tmp_name);
+
if (archive_exists) {
if (_g_mime_type_matches (archive->mime_type, "application/x-compressed-tar")) {
fr_process_begin_command (comm->process, "gzip");
@@ -933,6 +969,16 @@ fr_command_tar_uncompress (FrCommand *comm)
fr_process_add_arg (comm->process, tmp_name);
fr_process_end_command (comm->process);
}
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-lz4-compressed-tar")) {
+ fr_process_begin_command (comm->process, "lz4");
+ fr_process_set_working_dir (comm->process, tmp_dir);
+ fr_process_set_begin_func (comm->process, begin_func__uncompress, comm);
+ fr_process_add_arg (comm->process, "-f");
+ fr_process_add_arg (comm->process, "-d");
+ fr_process_add_arg (comm->process, tmp_name);
+ fr_process_add_arg (comm->process, c_tar->uncomp_filename);
+ fr_process_end_command (comm->process);
+ }
else if (_g_mime_type_matches (archive->mime_type, "application/x-lzip-compressed-tar")) {
fr_process_begin_command (comm->process, "lzip");
fr_process_set_begin_func (comm->process, begin_func__uncompress, comm);
@@ -992,7 +1038,6 @@ fr_command_tar_uncompress (FrCommand *comm)
}
}
- c_tar->uncomp_filename = get_uncompressed_name (c_tar, tmp_name);
g_free (tmp_name);
}
@@ -1013,6 +1058,7 @@ const char *tar_mime_types[] = { "application/x-compressed-tar",
"application/x-tar",
"application/x-7z-compressed-tar",
"application/x-lrzip-compressed-tar",
+ "application/x-lz4-compressed-tar",
"application/x-lzip-compressed-tar",
"application/x-lzma-compressed-tar",
"application/x-lzop-compressed-tar",
@@ -1063,6 +1109,10 @@ fr_command_tar_get_capabilities (FrArchive *archive,
if (_g_program_is_available ("lrzip", check_command))
capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
}
+ else if (_g_mime_type_matches (mime_type, "application/x-lz4-compressed-tar")) {
+ if (_g_program_is_available ("lz4", check_command))
+ capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
+ }
else if (_g_mime_type_matches (mime_type, "application/x-lzip-compressed-tar")) {
if (_g_program_is_available ("lzip", check_command))
capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
@@ -1135,6 +1185,8 @@ fr_command_tar_get_packages (FrArchive *archive,
return PACKAGES ("tar,gzip,ncompress");
else if (_g_mime_type_matches (mime_type, "application/x-lrzip-compressed-tar"))
return PACKAGES ("tar,lrzip");
+ else if (_g_mime_type_matches (mime_type, "application/x-lz4-compressed-tar"))
+ return PACKAGES ("tar,lz4");
else if (_g_mime_type_matches (mime_type, "application/x-lzip-compressed-tar"))
return PACKAGES ("tar,lzip");
else if (_g_mime_type_matches (mime_type, "application/x-lzma-compressed-tar"))
diff --git a/src/fr-init.c b/src/fr-init.c
index 356fa1c..1dd72ee 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -88,6 +88,7 @@ FrMimeTypeDescription mime_type_desc[] = {
{ "application/x-lrzip", ".lrz", 0 },
{ "application/x-lrzip-compressed-tar", ".tar.lrz", 0 },
{ "application/x-lz4", ".lz4", 0 },
+ { "application/x-lz4-compressed-tar", ".tar.lz4", 0 },
{ "application/x-lzip", ".lz", 0 },
{ "application/x-lzip-compressed-tar", ".tar.lz", 0 },
{ "application/x-lzma", ".lzma", 0 },
@@ -149,6 +150,7 @@ FrExtensionType file_ext_type[] = {
{ ".tar.gz", "application/x-compressed-tar" },
{ ".tar.lrz", "application/x-lrzip-compressed-tar" },
{ ".tar.lz", "application/x-lzip-compressed-tar" },
+ { ".tar.lz4", "application/x-lz4-compressed-tar" },
{ ".tar.lzma", "application/x-lzma-compressed-tar" },
{ ".tar.lzo", "application/x-lzop-compressed-tar" },
{ ".tar.7z", "application/x-7z-compressed-tar" },
@@ -161,6 +163,7 @@ FrExtensionType file_ext_type[] = {
{ ".tgz", "application/x-compressed-tar" },
{ ".txz", "application/x-xz-compressed-tar" },
{ ".tlz", "application/x-lzip-compressed-tar" },
+ { ".tlz4", "application/x-lz4-compressed-tar" },
{ ".tzma", "application/x-lzma-compressed-tar" },
{ ".tzo", "application/x-lzop-compressed-tar" },
{ ".war", "application/x-war" },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]