[file-roller] added support for lz4 compressed files
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] added support for lz4 compressed files
- Date: Wed, 17 Aug 2016 07:20:42 +0000 (UTC)
commit 8c0c81894d77cf1dd268423ba921ae99ff178f4b
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Aug 17 08:59:26 2016 +0200
added support for lz4 compressed files
[bug #770016]
data/org.gnome.FileRoller.desktop.in.in | 2 +-
src/fr-command-cfile.c | 34 +++++++++++++++++++++++++++---
src/fr-init.c | 2 +
3 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/data/org.gnome.FileRoller.desktop.in.in b/data/org.gnome.FileRoller.desktop.in.in
index badc2d7..74577d5 100644
--- a/data/org.gnome.FileRoller.desktop.in.in
+++ b/data/org.gnome.FileRoller.desktop.in.in
@@ -10,7 +10,7 @@ Type=Application
Icon=file-roller
Categories=GTK;GNOME;Utility;Archiving;Compression;X-GNOME-Utilities;
NotShowIn=KDE;
-MimeType=application/x-7z-compressed;application/x-7z-compressed-tar;application/x-ace;application/x-alz;application/x-ar;application/x-arj;application/x-bzip;application/x-bzip-compressed-tar;application/x-bzip1;application/x-bzip1-compressed-tar;application/x-cabinet;application/x-cbr;application/x-cbz;application/x-cd-image;application/x-compress;application/x-compressed-tar;application/x-cpio;application/x-deb;application/x-ear;application/x-ms-dos-executable;application/x-gtar;application/x-gzip;application/x-gzpostscript;application/x-java-archive;application/x-lha;application/x-lhz;application/x-lrzip;application/x-lrzip-compressed-tar;application/x-lzip;application/x-lzip-compressed-tar;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-lzop-compressed-tar;application/x-ms-wim;application/x-rar;application/x-rar-compressed;application/x-rpm;application/x-rzip;application/x-rzip-compressed-tar;application/x-tar;application/x-tarz;app
lication/x-stuffit;application/x-war;application/x-xz;application/x-xz-compressed-tar;application/x-zip;application/x-zip-compressed;application/x-zoo;application/zip;application/x-archive;application/vnd.ms-cab-compressed;application/vnd.debian.binary-package;application/gzip;
+MimeType=application/x-7z-compressed;application/x-7z-compressed-tar;application/x-ace;application/x-alz;application/x-ar;application/x-arj;application/x-bzip;application/x-bzip-compressed-tar;application/x-bzip1;application/x-bzip1-compressed-tar;application/x-cabinet;application/x-cbr;application/x-cbz;application/x-cd-image;application/x-compress;application/x-compressed-tar;application/x-cpio;application/x-deb;application/x-ear;application/x-ms-dos-executable;application/x-gtar;application/x-gzip;application/x-gzpostscript;application/x-java-archive;application/x-lha;application/x-lhz;application/x-lrzip;application/x-lrzip-compressed-tar;application/x-lz4;application/x-lzip;application/x-lzip-compressed-tar;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-lz4-compressed-tar;application/x-lzop-compressed-tar;application/x-ms-wim;application/x-rar;application/x-rar-compressed;application/x-rpm;application/x-rzip;application/x-rzip-comp
ressed-tar;application/x-tar;application/x-tarz;application/x-stuffit;application/x-war;application/x-xz;application/x-xz-compressed-tar;application/x-zip;application/x-zip-compressed;application/x-zoo;application/zip;application/x-archive;application/vnd.ms-cab-compressed;application/vnd.debian.binary-package;application/gzip;
X-GNOME-DocPath=file-roller/file-roller.xml
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=file-roller
diff --git a/src/fr-command-cfile.c b/src/fr-command-cfile.c
index 1fbc574..1f6cc1a 100644
--- a/src/fr-command-cfile.c
+++ b/src/fr-command-cfile.c
@@ -287,7 +287,18 @@ fr_command_cfile_add (FrCommand *comm,
fr_process_add_arg (comm->process, filename);
fr_process_end_command (comm->process);
compressed_filename = g_strconcat (filename, ".rz", NULL);
- } else {
+ }
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-lz4")) {
+ compressed_filename = g_strconcat (filename, ".lz4", NULL);
+ fr_process_begin_command (comm->process, "lz4");
+ fr_process_set_working_dir (comm->process, temp_dir);
+ fr_process_add_arg (comm->process, "-f");
+ fr_process_add_arg (comm->process, "-z");
+ fr_process_add_arg (comm->process, filename);
+ fr_process_add_arg (comm->process, compressed_filename);
+ fr_process_end_command (comm->process);
+ }
+ else {
g_warning ("Unhandled mime type: '%s'", archive->mime_type);
g_warn_if_reached ();
g_free (temp_file);
@@ -361,6 +372,8 @@ fr_command_cfile_extract (FrCommand *comm,
/* uncompress the file */
+ uncompr_file = _g_path_remove_first_extension (temp_file);
+
if (_g_mime_type_matches (archive->mime_type, "application/x-gzip")) {
fr_process_begin_command (comm->process, "gzip");
fr_process_add_arg (comm->process, "-f");
@@ -425,11 +438,18 @@ fr_command_cfile_extract (FrCommand *comm,
fr_process_add_arg (comm->process, temp_file);
fr_process_end_command (comm->process);
}
+ else if (_g_mime_type_matches (archive->mime_type, "application/x-lz4")) {
+ fr_process_begin_command (comm->process, "lz4");
+ fr_process_set_working_dir (comm->process, temp_dir);
+ fr_process_add_arg (comm->process, "-f");
+ fr_process_add_arg (comm->process, "-d");
+ fr_process_add_arg (comm->process, temp_file);
+ fr_process_add_arg (comm->process, uncompr_file);
+ fr_process_end_command (comm->process);
+ }
/* copy uncompress file to the dest dir */
- uncompr_file = _g_path_remove_first_extension (temp_file);
-
compr_file = get_uncompressed_name_from_archive (comm, comm->filename);
if (compr_file == NULL)
compr_file = _g_path_remove_first_extension (_g_path_get_basename (comm->filename));
@@ -463,6 +483,7 @@ fr_command_cfile_extract (FrCommand *comm,
const char *cfile_mime_type[] = { "application/x-gzip",
"application/x-bzip",
"application/x-compress",
+ "application/x-lz4",
"application/x-lzip",
"application/x-lzma",
"application/x-lzop",
@@ -521,7 +542,10 @@ fr_command_cfile_get_capabilities (FrArchive *archive,
if (_g_program_is_available ("rzip", check_command))
capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
}
-
+ else if (_g_mime_type_matches (mime_type, "application/x-lz4")) {
+ if (_g_program_is_available ("lz4", check_command))
+ capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
+ }
return capabilities;
}
@@ -546,6 +570,8 @@ fr_command_cfile_get_packages (FrArchive *archive,
return PACKAGES ("lzop");
else if (_g_mime_type_matches (mime_type, "application/x-rzip"))
return PACKAGES ("rzip");
+ else if (_g_mime_type_matches (mime_type, "application/x-lz4"))
+ return PACKAGES ("lz4");
return NULL;
}
diff --git a/src/fr-init.c b/src/fr-init.c
index e75f6d9..356fa1c 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -87,6 +87,7 @@ FrMimeTypeDescription mime_type_desc[] = {
{ "application/x-lha", ".lzh", 0 },
{ "application/x-lrzip", ".lrz", 0 },
{ "application/x-lrzip-compressed-tar", ".tar.lrz", 0 },
+ { "application/x-lz4", ".lz4", 0 },
{ "application/x-lzip", ".lz", 0 },
{ "application/x-lzip-compressed-tar", ".tar.lz", 0 },
{ "application/x-lzma", ".lzma", 0 },
@@ -134,6 +135,7 @@ FrExtensionType file_ext_type[] = {
{ ".lrz", "application/x-lrzip" },
{ ".lzh", "application/x-lha" },
{ ".lz", "application/x-lzip" },
+ { ".lz4", "application/x-lz4" },
{ ".lzma", "application/x-lzma" },
{ ".lzo", "application/x-lzop" },
{ ".rar", "application/x-rar" },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]