[file-roller/gnome-3-10] Cannot extract .tar.lzop archives



commit 01ff0930ba3a491c0bd636076a79405173d27001
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Dec 28 15:39:36 2013 +0100

    Cannot extract .tar.lzop archives
    
    [bug #720279]

 src/fr-command-cfile.c |   10 +++++-----
 src/glib-utils.c       |   19 +++++++++++++++++++
 src/glib-utils.h       |    1 +
 3 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/src/fr-command-cfile.c b/src/fr-command-cfile.c
index 6b15768..1fbc574 100644
--- a/src/fr-command-cfile.c
+++ b/src/fr-command-cfile.c
@@ -113,7 +113,7 @@ list__process_line (char     *line,
 
        filename = get_uncompressed_name_from_archive (comm, comm->filename);
        if (filename == NULL)
-               filename = _g_path_remove_extension (comm->filename);
+               filename = _g_path_remove_first_extension (comm->filename);
 
        fdata->full_path = g_strconcat ("/", _g_path_get_basename (filename), NULL);
        g_free (filename);
@@ -161,7 +161,7 @@ fr_command_cfile_list (FrCommand *comm)
 
                fdata = file_data_new ();
 
-               filename = _g_path_remove_extension (comm->filename);
+               filename = _g_path_remove_first_extension (comm->filename);
                fdata->full_path = g_strconcat ("/",
                                                _g_path_get_basename (filename),
                                                NULL);
@@ -428,11 +428,11 @@ fr_command_cfile_extract (FrCommand  *comm,
 
        /* copy uncompress file to the dest dir */
 
-       uncompr_file = _g_path_remove_extension (temp_file);
+       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_extension (_g_path_get_basename (comm->filename));
+               compr_file = _g_path_remove_first_extension (_g_path_get_basename (comm->filename));
        dest_file = g_strconcat (dest_dir,
                                 "/",
                                 compr_file,
@@ -516,7 +516,7 @@ 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/glib-utils.c b/src/glib-utils.c
index f63824e..03ae634 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -960,6 +960,9 @@ _g_path_remove_extension (const gchar *path)
 {
        const char *ext;
 
+       if (path == NULL)
+               return NULL;
+
        ext = _g_filename_get_extension (path);
        if (ext == NULL)
                return g_strdup (path);
@@ -968,6 +971,22 @@ _g_path_remove_extension (const gchar *path)
 }
 
 
+char *
+_g_path_remove_first_extension (const gchar *path)
+{
+       const char *ext;
+
+       if (path == NULL)
+               return NULL;
+
+       ext = strrchr (path, '.');
+       if (ext == NULL)
+               return g_strdup (path);
+       else
+               return g_strndup (path, strlen (path) - strlen (ext));
+}
+
+
 /* Check whether the dirname is contained in filename */
 gboolean
 _g_path_is_parent_of (const char *dirname,
diff --git a/src/glib-utils.h b/src/glib-utils.h
index fef339c..eb6f8a9 100644
--- a/src/glib-utils.h
+++ b/src/glib-utils.h
@@ -140,6 +140,7 @@ char *              _g_path_get_dir_name           (const char          *path);
 char *              _g_path_remove_level           (const char          *path);
 char *              _g_path_remove_ending_separator(const char          *path);
 char *              _g_path_remove_extension       (const char          *path);
+char *             _g_path_remove_first_extension (const gchar         *path);
 gboolean            _g_path_is_parent_of           (const char          *dirname,
                                                    const char          *filename);
 const char *        _g_path_get_relative_basename  (const char          *path,


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