[file-roller] Support for Zstandard compressed tar archives (.tar.zst, .tzst)
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] Support for Zstandard compressed tar archives (.tar.zst, .tzst)
- Date: Sat, 12 Oct 2019 15:08:31 +0000 (UTC)
commit cc6b0305288c60b6acb022af2b999f95d8ab2f67
Author: Felix Riemann <friemann gnome org>
Date: Sat Feb 2 19:07:06 2019 +0100
Support for Zstandard compressed tar archives (.tar.zst, .tzst)
README | 1 +
data/packages.match | 2 +-
data/supported-mime-types | 1 +
src/fr-command-tar.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
src/fr-init.c | 3 +++
5 files changed, 57 insertions(+), 1 deletion(-)
---
diff --git a/README b/README
index 05581298..7a4765a4 100644
--- a/README
+++ b/README
@@ -42,6 +42,7 @@
* lzop (.tar.lzo , .tzo)
* 7zip (.tar.7z)
* xz (.tar.xz)
+ * Zstandard (.tar.zst, .tzst)
* Snap packages (.snap)
* Squashfs images (.sqsh)
* Stuffit Archives (.bin, .sit)
diff --git a/data/packages.match b/data/packages.match
index 4d80a4d6..68ce591f 100644
--- a/data/packages.match
+++ b/data/packages.match
@@ -28,5 +28,5 @@ unstaff=
unzip=
xz=
zip=
+zstd=
zoo=
-
diff --git a/data/supported-mime-types b/data/supported-mime-types
index 8d0c8c72..fff26752 100644
--- a/data/supported-mime-types
+++ b/data/supported-mime-types
@@ -56,5 +56,6 @@ application/x-xz;
application/x-xz-compressed-tar;
application/x-zip;
application/x-zip-compressed;
+application/x-zstd-compressed-tar;
application/x-zoo;
application/zip;
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index 13e08f9e..d3f59c00 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -232,6 +232,9 @@ add_compress_arg (FrCommand *comm)
else if (_g_mime_type_matches (archive->mime_type, "application/x-lzop-compressed-tar"))
fr_process_add_arg (comm->process, "--use-compress-program=lzop");
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-zstd-compressed-tar"))
+ fr_process_add_arg (comm->process, "--use-compress-program=zstd");
+
else if (_g_mime_type_matches (archive->mime_type, "application/x-7z-compressed-tar")) {
FrCommandTar *comm_tar = (FrCommandTar*) comm;
char *option;
@@ -762,6 +765,27 @@ fr_command_tar_recompress (FrCommand *comm)
new_name = g_strconcat (c_tar->uncomp_filename, ".rz", NULL);
}
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-zstd-compressed-tar")) {
+ fr_process_begin_command (comm->process, "zstd");
+ 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, "-2"); break;
+ case FR_COMPRESSION_NORMAL:
+ fr_process_add_arg (comm->process, "-3"); break;
+ case FR_COMPRESSION_MAXIMUM:
+ fr_process_add_arg (comm->process, "--ultra");
+ fr_process_add_arg (comm->process, "-22");
+ break;
+ }
+ fr_process_add_arg (comm->process, "-f");
+ fr_process_add_arg (comm->process, c_tar->uncomp_filename);
+ fr_process_end_command (comm->process);
+
+ new_name = g_strconcat (c_tar->uncomp_filename, ".zst", NULL);
+ }
if (c_tar->name_modified) {
char *tmp_dir;
@@ -909,6 +933,17 @@ get_uncompressed_name (FrCommandTar *c_tar,
if (_g_filename_has_extension (e_filename, ".tar.rz"))
new_name[l - 3] = 0;
}
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-zstd-compressed-tar")) {
+ /* X.tzst --> X.tar
+ * X.tar.zst --> X.tar */
+ if (_g_filename_has_extension (e_filename, ".tzst")) {
+ new_name[l - 3] = 'a';
+ new_name[l - 2] = 'r';
+ new_name[l - 1] = 0;
+ }
+ else if (_g_filename_has_extension (e_filename, ".tar.zst"))
+ new_name[l - 4] = 0;
+ }
return new_name;
}
@@ -1096,6 +1131,15 @@ 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-zstd-compressed-tar")) {
+ fr_process_begin_command (comm->process, "zstd");
+ 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_end_command (comm->process);
+ }
}
g_free (tmp_dir);
@@ -1127,6 +1171,7 @@ const char *tar_mime_types[] = { "application/x-compressed-tar",
"application/x-rzip-compressed-tar",
"application/x-tarz",
"application/x-xz-compressed-tar",
+ "application/x-zstd-compressed-tar",
NULL };
@@ -1210,6 +1255,10 @@ fr_command_tar_get_capabilities (FrArchive *archive,
if(_g_program_is_available ("rzip", check_command))
capabilities |= FR_ARCHIVE_CAN_WRITE;
}
+ else if (_g_mime_type_matches (mime_type, "application/x-zstd-compressed-tar")) {
+ if (_g_program_is_available ("zstd", check_command))
+ capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
+ }
return capabilities;
}
@@ -1267,6 +1316,8 @@ fr_command_tar_get_packages (FrArchive *archive,
return PACKAGES ("tar,p7zip");
else if (_g_mime_type_matches (mime_type, "application/x-rzip-compressed-tar"))
return PACKAGES ("tar,rzip");
+ else if (_g_mime_type_matches (mime_type, "application/x-zstd-compressed-tar"))
+ return PACKAGES ("tar,zstd");
return NULL;
}
diff --git a/src/fr-init.c b/src/fr-init.c
index 011c1d06..9639fe90 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -116,6 +116,7 @@ FrMimeTypeDescription mime_type_desc[] = {
{ "application/x-xz", ".xz", 0 },
{ "application/x-xz-compressed-tar", ".tar.xz", 0 },
{ "application/x-zoo", ".zoo", 0 },
+ { "application/x-zstd-compressed-tar", ".tar.zst", 0 },
{ "application/zip", ".zip", 0 },
{ NULL, NULL, 0 }
};
@@ -172,6 +173,7 @@ FrExtensionType file_ext_type[] = {
{ ".tar.rz", "application/x-rzip-compressed-tar" },
{ ".tar.xz", "application/x-xz-compressed-tar" },
{ ".tar.Z", "application/x-tarz" },
+ { ".tar.zst", "application/x-zstd-compressed-tar" },
{ ".taz", "application/x-tarz" },
{ ".tbz", "application/x-bzip-compressed-tar" },
{ ".tbz2", "application/x-bzip-compressed-tar" },
@@ -181,6 +183,7 @@ FrExtensionType file_ext_type[] = {
{ ".tlz4", "application/x-lz4-compressed-tar" },
{ ".tzma", "application/x-lzma-compressed-tar" },
{ ".tzo", "application/x-lzop-compressed-tar" },
+ { ".tzst", "application/x-zstd-compressed-tar" },
{ ".war", "application/x-war" },
{ ".wim", "application/x-ms-wim" },
{ ".xar", "application/x-xar" },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]