[file-roller] Added support for brotli (*.tar.br) compressed tar archives
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] Added support for brotli (*.tar.br) compressed tar archives
- Date: Fri, 11 Jan 2019 09:49:27 +0000 (UTC)
commit dd44d39638fb1cb918e0db8ae70e7281a96d38d1
Author: Sergey Ponomarev <stokito gmail com>
Date: Sat Nov 10 14:19:05 2018 +0200
Added support for brotli (*.tar.br) compressed tar archives
README | 1 +
data/supported-mime-types | 1 +
nautilus/nautilus-fileroller.c | 1 +
src/fr-command-tar.c | 43 ++++++++++++++++++++++++++++++++++++++++++
src/fr-init.c | 2 ++
5 files changed, 48 insertions(+)
---
diff --git a/README b/README
index 9fffb7b2..dc543551 100644
--- a/README
+++ b/README
@@ -33,6 +33,7 @@
* uncompressed (.tar)
or compressed with:
* gzip (.tar.gz , .tgz)
+ * brotli (.tar.br)
* bzip (.tar.bz , .tbz)
* bzip2 (.tar.bz2 , .tbz2)
* compress (.tar.Z , .taz)
diff --git a/data/supported-mime-types b/data/supported-mime-types
index 7dad1f3e..8d0c8c72 100644
--- a/data/supported-mime-types
+++ b/data/supported-mime-types
@@ -11,6 +11,7 @@ application/x-ar;
application/x-archive;
application/x-arj;
application/x-brotli;
+application/x-bzip-brotli-tar;
application/x-bzip;
application/x-bzip-compressed-tar;
application/x-bzip1;
diff --git a/nautilus/nautilus-fileroller.c b/nautilus/nautilus-fileroller.c
index eb6e3e57..c43b041b 100644
--- a/nautilus/nautilus-fileroller.c
+++ b/nautilus/nautilus-fileroller.c
@@ -115,6 +115,7 @@ static struct {
{ "application/x-ar", TRUE },
{ "application/x-arj", TRUE },
{ "application/x-brotli", TRUE },
+ { "application/x-brotli-compressed-tar", TRUE },
{ "application/vnd.ms-cab-compressed", TRUE },
{ "application/x-cbr", TRUE },
{ "application/x-cbz", TRUE },
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index 5e56b719..13e08f9e 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -202,6 +202,9 @@ add_compress_arg (FrCommand *comm)
if (_g_mime_type_matches (archive->mime_type, "application/x-compressed-tar"))
fr_process_add_arg (comm->process, "-z");
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-brotli-compressed-tar"))
+ fr_process_add_arg (comm->process, "--use-compress-program=brotli");
+
else if (_g_mime_type_matches (archive->mime_type, "application/x-bzip-compressed-tar"))
fr_process_add_arg (comm->process, "--use-compress-program=bzip2");
@@ -544,6 +547,25 @@ fr_command_tar_recompress (FrCommand *comm)
new_name = g_strconcat (c_tar->uncomp_filename, ".gz", NULL);
}
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-brotli-compressed-tar")) {
+ fr_process_begin_command (comm->process, "brotli");
+ 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, "--best"); break; // i.e. -q 11
+ }
+ 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, ".br", NULL);
+ }
else if (_g_mime_type_matches (archive->mime_type, "application/x-bzip-compressed-tar")) {
fr_process_begin_command (comm->process, "bzip2");
fr_process_set_begin_func (comm->process, begin_func__recompress, comm);
@@ -799,6 +821,11 @@ get_uncompressed_name (FrCommandTar *c_tar,
else if (_g_filename_has_extension (e_filename, ".tar.gz"))
new_name[l - 3] = 0;
}
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-brotli-compressed-tar")) {
+ /* X.tar.br --> X.tar */
+ if (_g_filename_has_extension (e_filename, ".tar.br"))
+ new_name[l - 3] = 0;
+ }
else if (_g_mime_type_matches (archive->mime_type, "application/x-bzip-compressed-tar")) {
/* X.tbz2 --> X.tar
* X.tar.bz2 --> X.tar */
@@ -956,6 +983,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-brotli-compressed-tar")) {
+ fr_process_begin_command (comm->process, "brotli");
+ 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);
+ }
else if (_g_mime_type_matches (archive->mime_type, "application/x-bzip-compressed-tar")) {
fr_process_begin_command (comm->process, "bzip2");
fr_process_set_working_dir (comm->process, tmp_dir);
@@ -1079,6 +1115,7 @@ fr_command_tar_handle_error (FrCommand *comm,
const char *tar_mime_types[] = { "application/x-compressed-tar",
+ "application/x-brotli-compressed-tar",
"application/x-bzip-compressed-tar",
"application/x-tar",
"application/x-7z-compressed-tar",
@@ -1120,6 +1157,10 @@ fr_command_tar_get_capabilities (FrArchive *archive,
if (_g_program_is_available ("gzip", check_command))
capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
}
+ else if (_g_mime_type_matches (mime_type, "application/x-brotli-compressed-tar")) {
+ if (_g_program_is_available ("brotli", check_command))
+ capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
+ }
else if (_g_mime_type_matches (mime_type, "application/x-bzip-compressed-tar")) {
if (_g_program_is_available ("bzip2", check_command))
capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
@@ -1204,6 +1245,8 @@ fr_command_tar_get_packages (FrArchive *archive,
return PACKAGES ("tar");
else if (_g_mime_type_matches (mime_type, "application/x-compressed-tar"))
return PACKAGES ("tar,gzip");
+ else if (_g_mime_type_matches (mime_type, "application/x-brotli-compressed-tar"))
+ return PACKAGES ("tar,brotli");
else if (_g_mime_type_matches (mime_type, "application/x-bzip-compressed-tar"))
return PACKAGES ("tar,bzip2");
else if (_g_mime_type_matches (mime_type, "application/x-tarz"))
diff --git a/src/fr-init.c b/src/fr-init.c
index 750ab9ce..011c1d06 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -70,6 +70,7 @@ FrMimeTypeDescription mime_type_desc[] = {
{ "application/x-ar", ".ar", 0 },
{ "application/x-arj", ".arj", 0 },
{ "application/x-brotli", ".br", 0 },
+ { "application/x-brotli-compressed-tar", ".tar.br", 0 },
{ "application/x-bzip", ".bz2", 0 },
{ "application/x-bzip-compressed-tar", ".tar.bz2", 0 },
{ "application/x-bzip1", ".bz", 0 },
@@ -158,6 +159,7 @@ FrExtensionType file_ext_type[] = {
{ ".sqsh", "application/vnd.squashfs" },
{ ".swm", "application/x-ms-wim" },
{ ".tar", "application/x-tar" },
+ { ".tar.br", "application/x-brotli-compressed-tar" },
{ ".tar.bz", "application/x-bzip-compressed-tar" },
{ ".tar.bz2", "application/x-bzip-compressed-tar" },
{ ".tar.gz", "application/x-compressed-tar" },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]