[file-roller] Add .tar.rz support



commit 5c4f66087997aeace75829607c5eec4563226746
Author: LAN-TW <lantw44 gmail com>
Date:   Sun Apr 28 12:09:06 2013 +0800

    Add .tar.rz support

 src/fr-command-cfile.c |    3 ++-
 src/fr-command-tar.c   |   42 +++++++++++++++++++++++++++++++++++++++++-
 src/fr-init.c          |    2 ++
 src/glib-utils.c       |    3 ++-
 4 files changed, 47 insertions(+), 3 deletions(-)
---
diff --git a/src/fr-command-cfile.c b/src/fr-command-cfile.c
index ce2df59..f874d0a 100644
--- a/src/fr-command-cfile.c
+++ b/src/fr-command-cfile.c
@@ -509,7 +509,8 @@ fr_command_cfile_get_capabilities (FrArchive  *archive,
                if (_g_program_is_available ("lzop", check_command))
                        capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
        }
-       else if (_g_mime_type_matches (mime_type, "application/x-rzip")) {
+       else if (_g_mime_type_matches (mime_type, "application/x-rzip") || 
+                _g_mime_type_matches (mime_type, "application/x-rzip-compressed-tar")) {
                if (_g_program_is_available ("rzip", check_command))
                        capabilities |= FR_ARCHIVE_CAN_READ_WRITE;
        }
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index 8ef36e5..4cd7837 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -268,7 +268,9 @@ fr_command_tar_list (FrCommand *comm)
 static gboolean
 can_create_a_compressed_archive (FrCommand *comm)
 {
-       return comm->creating_archive && ! _g_mime_type_matches (FR_ARCHIVE (comm)->mime_type, 
"application/x-7z-compressed-tar");
+       return comm->creating_archive && 
+               ! _g_mime_type_matches (FR_ARCHIVE (comm)->mime_type, "application/x-7z-compressed-tar") &&
+               ! _g_mime_type_matches (FR_ARCHIVE (comm)->mime_type, "application/x-rzip-compressed-tar");
 }
 
 
@@ -687,6 +689,25 @@ fr_command_tar_recompress (FrCommand *comm)
                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-rzip-compressed-tar")) {
+               fr_process_begin_command (comm->process, "rzip");
+               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, "-L1"); break;
+               case FR_COMPRESSION_FAST:
+                       fr_process_add_arg (comm->process, "-L3"); break;
+               case FR_COMPRESSION_NORMAL:
+                       fr_process_add_arg (comm->process, "-L6"); break;
+               case FR_COMPRESSION_MAXIMUM:
+                       fr_process_add_arg (comm->process, "-L9"); 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, ".rz", NULL);
+       }
 
        if (c_tar->name_modified) {
                char *tmp_dir;
@@ -813,6 +834,11 @@ get_uncompressed_name (FrCommandTar *c_tar,
                if (_g_filename_has_extension (e_filename, ".tar.7z"))
                        new_name[l - 3] = 0;
        }
+       else if (_g_mime_type_matches (archive->mime_type, "application/x-rzip-compressed-tar")) {
+               /* X.tar.rz -->  X.tar */
+               if (_g_filename_has_extension (e_filename, ".tar.rz"))
+                       new_name[l - 3] = 0;
+       }
 
        return new_name;
 }
@@ -960,6 +986,13 @@ 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-rzip-compressed-tar")) {
+                       fr_process_begin_command (comm->process, "rzip");
+                       fr_process_set_begin_func (comm->process, begin_func__uncompress, comm);
+                       fr_process_add_arg (comm->process, "-df");
+                       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);
@@ -986,6 +1019,7 @@ const char *tar_mime_types[] = { "application/x-compressed-tar",
                                 "application/x-lzip-compressed-tar",
                                 "application/x-lzma-compressed-tar",
                                 "application/x-lzop-compressed-tar",
+                                "application/x-rzip-compressed-tar",
                                 "application/x-tarz",
                                 "application/x-xz-compressed-tar",
                                 NULL };
@@ -1059,6 +1093,10 @@ fr_command_tar_get_capabilities (FrArchive  *archive,
                        }
                }
        }
+       else if(_g_mime_type_matches (mime_type, "application/x-rzip-compressed-tar")) {
+               if(_g_program_is_available ("rzip", check_command))
+                       capabilities |= FR_ARCHIVE_CAN_WRITE;
+       }
 
        return capabilities;
 }
@@ -1110,6 +1148,8 @@ fr_command_tar_get_packages (FrArchive  *archive,
                return PACKAGES ("tar,lzop");
        else if (_g_mime_type_matches (mime_type, "application/x-7z-compressed-tar"))
                return PACKAGES ("tar,p7zip");
+       else if (_g_mime_type_matches (mime_type, "application/x-rzip-compressed-tar"))
+               return PACKAGES ("tar,rzip");
 
        return NULL;
 }
diff --git a/src/fr-init.c b/src/fr-init.c
index f4a7c83..2c3ad75 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -96,6 +96,7 @@ FrMimeTypeDescription mime_type_desc[] = {
        { "application/x-rar",                  ".rar",      0 },
        { "application/x-rpm",                  ".rpm",      0 },
        { "application/x-rzip",                 ".rz",       0 },
+       { "application/x-rzip-compressed-tar",  ".tar.rz",   0 },
        { "application/x-tar",                  ".tar",      0 },
        { "application/x-tarz",                 ".tar.Z",    0 },
        { "application/x-stuffit",              ".sit",      0 },
@@ -147,6 +148,7 @@ FrExtensionType file_ext_type[] = {
        { ".tar.lzma", "application/x-lzma-compressed-tar" },
        { ".tar.lzo", "application/x-lzop-compressed-tar" },
        { ".tar.7z", "application/x-7z-compressed-tar" },
+       { ".tar.rz", "application/x-rzip-compressed-tar" },
        { ".tar.xz", "application/x-xz-compressed-tar" },
        { ".tar.Z", "application/x-tarz" },
        { ".taz", "application/x-tarz" },
diff --git a/src/glib-utils.c b/src/glib-utils.c
index 8f086d4..503f0e7 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -1051,7 +1051,8 @@ _g_filename_get_extension (const char *filename)
        ext = filename + p;
        if (ext - 4 > filename) {
                const char *test = ext - 4;
-               if (strncmp (test, ".tar", 4) == 0)
+               /* .tar.rz cannot be uncompressed in one step */
+               if (strncmp (test, ".tar", 4) == 0 && strncmp(ext, ".rz", 2) != 0)
                        ext = ext - 4;
        }
        return ext;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]