[evince] libdocument: Add xz compression support
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] libdocument: Add xz compression support
- Date: Sat, 4 Dec 2010 21:10:31 +0000 (UTC)
commit 38cfc027fc96ac19452c3138614e2c8deff63633
Author: Christian Persch <chpe gnome org>
Date: Sat Dec 4 22:09:55 2010 +0100
libdocument: Add xz compression support
libdocument/ev-document-factory.c | 2 ++
libdocument/ev-file-helpers.c | 14 ++++++++++----
libdocument/ev-file-helpers.h | 3 ++-
3 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/libdocument/ev-document-factory.c b/libdocument/ev-document-factory.c
index 2bed390..1f1eb0d 100644
--- a/libdocument/ev-document-factory.c
+++ b/libdocument/ev-document-factory.c
@@ -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;
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index edd4e4f..cab0ad5 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -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;
}
diff --git a/libdocument/ev-file-helpers.h b/libdocument/ev-file-helpers.h
index fffae03..0abc5c2 100644
--- a/libdocument/ev-file-helpers.h
+++ b/libdocument/ev-file-helpers.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]