]> www.fi.muni.cz Git - evince.git/commitdiff
libdocument: Add xz compression support
authorChristian Persch <chpe@gnome.org>
Sat, 4 Dec 2010 21:09:55 +0000 (22:09 +0100)
committerChristian Persch <chpe@gnome.org>
Sat, 4 Dec 2010 21:09:55 +0000 (22:09 +0100)
libdocument/ev-document-factory.c
libdocument/ev-file-helpers.c
libdocument/ev-file-helpers.h

index 2bed390699618a120f46eca1fbb5d42f1e98a018..1f1eb0dbcfb080e5ca34af58fa51384b9e47d240 100644 (file)
@@ -47,6 +47,8 @@ get_compression_from_mime_type (const gchar *mime_type)
                        return EV_COMPRESSION_GZIP;
                else if (g_ascii_strcasecmp (type, "bz") == 0)
                        return EV_COMPRESSION_BZIP2;
+                else if (g_ascii_strcasecmp (type, "xz") == 0)
+                        return EV_COMPRESSION_LZMA;
        }
 
        return EV_COMPRESSION_NONE;
index edd4e4fd0adc2414e6918cab61dc7bceb4ce75e8..cab0ad542c250e1b872bb3b4f875655e83d8a15b 100644 (file)
@@ -525,8 +525,14 @@ ev_file_get_mime_type (const gchar *uri,
 }
 
 /* Compressed files support */
-#define BZIPCOMMAND "bzip2"
-#define GZIPCOMMAND "gzip"
+
+static const char *compressor_cmds[] = {
+  NULL,
+  "bzip2",
+  "gzip",
+  "xz"
+};
+
 #define N_ARGS      4
 #define BUFFER_SIZE 1024
 
@@ -546,13 +552,13 @@ compression_run (const gchar       *uri,
        if (type == EV_COMPRESSION_NONE)
                return NULL;
 
-       cmd = g_find_program_in_path ((type == EV_COMPRESSION_BZIP2) ? BZIPCOMMAND : GZIPCOMMAND);
+       cmd = g_find_program_in_path (compressor_cmds[type]);
        if (!cmd) {
                /* FIXME: better error codes! */
                /* FIXME: i18n later */
                g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                             "Failed to find the \"%s\" command in the search path.",
-                            type == EV_COMPRESSION_BZIP2 ? BZIPCOMMAND : GZIPCOMMAND);
+                             compressor_cmds[type]);
                return NULL;
        }
 
index fffae03ffc7c046d80f1a696e1a36d632bdc4470..0abc5c281942a8d39faf7f94b7e6d8558541aee4 100644 (file)
@@ -32,7 +32,8 @@ G_BEGIN_DECLS
 typedef enum {
        EV_COMPRESSION_NONE,
        EV_COMPRESSION_BZIP2,
-       EV_COMPRESSION_GZIP
+       EV_COMPRESSION_GZIP,
+        EV_COMPRESSION_LZMA
 } EvCompressionType;
 
 void        _ev_file_helpers_init     (void);