From: Tomas Mlcoch Date: Thu, 12 Apr 2012 12:00:45 +0000 (+0200) Subject: Use MAGIC_MIME instead of MAGIC_MIME_TYPE. X-Git-Tag: upstream/0.2.1~441 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e9bca103a7bd040b29b0443f8a7cb2230d9dadd;p=services%2Fcreaterepo_c.git Use MAGIC_MIME instead of MAGIC_MIME_TYPE. --- diff --git a/src/compression_wrapper.c b/src/compression_wrapper.c index b5f76b3..d5c42cf 100644 --- a/src/compression_wrapper.c +++ b/src/compression_wrapper.c @@ -53,17 +53,24 @@ CompressionType detect_compression(const char *filename) // Try determine compression type via filename suffix if (g_str_has_suffix(filename, ".gz") || - g_str_has_suffix(filename, ".gzip")) + g_str_has_suffix(filename, ".gzip") || + g_str_has_suffix(filename, ".gunzip")) { return GZ_COMPRESSION; - } else if (g_str_has_suffix(filename, ".bz2")) { + } else if (g_str_has_suffix(filename, ".bz2") || + g_str_has_suffix(filename, ".bzip2")) + { return BZ2_COMPRESSION; + } else if (g_str_has_suffix(filename, ".xml")) + { + return NO_COMPRESSION; } // No success? Let's get hardcore... (Use magic bytes) - magic_t myt = magic_open(MAGIC_MIME_TYPE); + //magic_t myt = magic_open(MAGIC_MIME_TYPE); + magic_t myt = magic_open(MAGIC_MIME); magic_load(myt, NULL); if (magic_check(myt, NULL) == -1) { g_critical(MODULE"%s: magic_check() failed", __func__); @@ -75,17 +82,35 @@ CompressionType detect_compression(const char *filename) if (mime_type) { g_debug(MODULE"%s: Detected mime type: %s", __func__, mime_type); - if (g_str_has_suffix(mime_type, "gzip") || - g_str_has_suffix(mime_type, "gunzip")) +// if (g_str_has_suffix(mime_type, "gzip") || +// g_str_has_suffix(mime_type, "gunzip")) + if (g_str_has_prefix(mime_type, "application/x-gzip") || + g_str_has_prefix(mime_type, "application/gzip") || + g_str_has_prefix(mime_type, "application/gzip-compressed") || + g_str_has_prefix(mime_type, "application/gzipped") || + g_str_has_prefix(mime_type, "application/x-gzip-compressed") || + g_str_has_prefix(mime_type, "application/x-compress") || + g_str_has_prefix(mime_type, "application/x-gzip") || + g_str_has_prefix(mime_type, "application/x-gunzip") || + g_str_has_prefix(mime_type, "multipart/x-gzip")) { type = GZ_COMPRESSION; } - else if (g_str_has_suffix(mime_type, "bzip2")) { +// else if (g_str_has_suffix(mime_type, "bzip2")) { + else if (g_str_has_prefix(mime_type, "application/x-bzip2") || + g_str_has_prefix(mime_type, "application/x-bz2") || + g_str_has_prefix(mime_type, "application/bzip2") || + g_str_has_prefix(mime_type, "application/bz2")) + { type = BZ2_COMPRESSION; } - else if (!g_strcmp0(mime_type, "text/plain")) { +// else if (!g_strcmp0(mime_type, "text/plain")) { + else if (g_str_has_prefix(mime_type, "application/xml") || + g_str_has_prefix(mime_type, "application/x-xml") || + g_str_has_prefix(mime_type, "text/xml")) + { type = NO_COMPRESSION; } } else {