summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2019-09-15 23:30:48 +0200
committerlukefromdc <[email protected]>2019-10-03 03:31:21 +0000
commit62e3fa54b0770ae4cb789688952b7013a3df28e6 (patch)
tree1c93080341a18c64b2bd7182e67f19fce9290c4b
parentd054028b841d3f29fbe7f9bd57163ce4d125794f (diff)
downloadengrampa-62e3fa54b0770ae4cb789688952b7013a3df28e6.tar.bz2
engrampa-62e3fa54b0770ae4cb789688952b7013a3df28e6.tar.xz
Zstandard: read .tar.zst files
$ tar cafv ~/test.tar.zst ~/test $ xdg-mime query filetype ~/test.tar.zst application/x-zstd-compressed-tar Test: $ CFLAGS="-g -O0" ./autogen.sh --enable-magic --enable-packagekit --prefix=/usr && make && sudo make install $ engrampa ~/test.tar.zst
-rw-r--r--caja/caja-engrampa.c1
-rw-r--r--src/fr-command-tar.c20
-rw-r--r--src/fr-init.c2
3 files changed, 23 insertions, 0 deletions
diff --git a/caja/caja-engrampa.c b/caja/caja-engrampa.c
index eb7fb45..d262f49 100644
--- a/caja/caja-engrampa.c
+++ b/caja/caja-engrampa.c
@@ -192,6 +192,7 @@ static struct {
{ "application/x-zip-compressed", TRUE },
{ "application/x-zoo", TRUE },
{ "application/x-zstd", TRUE },
+ { "application/x-zstd-compressed-tar", TRUE },
{ "application/zip", TRUE },
{ "multipart/x-zip", TRUE },
{ NULL, FALSE }
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index 3c47399..ffa911d 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -827,6 +827,11 @@ get_uncompressed_name (FrCommandTar *c_tar,
if (file_extension_is (e_filename, ".tar.7z"))
new_name[l - 3] = 0;
}
+ else if (is_mime_type (comm->mime_type, "application/x-zstd-compressed-tar")) {
+ /* X.tar.zst --> X.tar */
+ if (file_extension_is (e_filename, ".tar.zst"))
+ new_name[l - 4] = 0;
+ }
return new_name;
}
@@ -980,6 +985,14 @@ fr_command_tar_uncompress (FrCommand *comm)
fr_process_add_arg (comm->process, tmp_name);
fr_process_end_command (comm->process);
}
+ else if (is_mime_type (comm->mime_type, "application/x-zstd-compressed-tar")) {
+ fr_process_begin_command (comm->process, "zstd");
+ 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);
+ }
}
c_tar->uncomp_filename = get_uncompressed_name (c_tar, tmp_name);
@@ -1009,6 +1022,7 @@ const char *tar_mime_types[] = { "application/x-compressed-tar",
"application/x-lzop-compressed-tar",
"application/x-tarz",
"application/x-xz-compressed-tar",
+ "application/x-zstd-compressed-tar",
NULL };
@@ -1084,6 +1098,10 @@ fr_command_tar_get_capabilities (FrCommand *comm,
}
}
}
+ else if (is_mime_type (mime_type, "application/x-zstd-compressed-tar")) {
+ if (is_program_available ("zstd", check_command))
+ capabilities |= FR_COMMAND_CAN_READ;
+ }
return capabilities;
}
@@ -1137,6 +1155,8 @@ fr_command_tar_get_packages (FrCommand *comm,
return PACKAGES ("tar,lzop");
else if (is_mime_type (mime_type, "application/x-7z-compressed-tar"))
return PACKAGES ("tar,p7zip");
+ else if (is_mime_type (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 34b1611..2abf248 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -111,6 +111,7 @@ FrMimeTypeDescription mime_type_desc[] = {
{ "application/x-xz-compressed-tar", ".tar.xz", N_("Tar compressed with xz (.tar.xz)"), 0 },
{ "application/x-zoo", ".zoo", N_("Zoo (.zoo)"), 0 },
{ "application/x-zstd", ".zst", N_("Zstandard (.zst)"), 0 },
+ { "application/x-zstd-compressed-tar", ".tar.zst", N_("Tar compressed with zstd (.tar.zst)"), 0 },
{ "application/zip", ".zip", N_("Zip (.zip)"), 0 },
{ NULL, NULL, NULL, 0 }
};
@@ -165,6 +166,7 @@ FrExtensionType file_ext_type[] = {
{ ".tar.lzo", "application/x-lzop-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" },