Fix GZlibCompressorFormat names

What used to be called RAW is really the zlib header format.
There is a real "raw" format, so rename the default and add a RAW type.
This commit is contained in:
Alexander Larsson 2009-11-24 13:02:05 +01:00
parent 85501f5ffa
commit 2af69f4135
4 changed files with 24 additions and 9 deletions

View File

@ -675,8 +675,9 @@ typedef enum {
/** /**
* GZlibCompressorFormat: * GZlibCompressorFormat:
* @G_ZLIB_COMRESSOR_FORMAT_RAW: Raw zlib compression data * @G_ZLIB_COMRESSOR_FORMAT_ZLIB: deflate compression with zlib header
* @G_ZLIB_COMRESSOR_FORMAT_GZIP: gzip file format * @G_ZLIB_COMRESSOR_FORMAT_GZIP: gzip file format
* @G_ZLIB_COMRESSOR_FORMAT_RAW: deflate compression with no header
* *
* Used to select the type of data format to use for #GZlibDecompressor * Used to select the type of data format to use for #GZlibDecompressor
* and #GZlibCompressor. * and #GZlibCompressor.
@ -684,8 +685,9 @@ typedef enum {
* Since: 2.24 * Since: 2.24
*/ */
typedef enum { typedef enum {
G_ZLIB_COMPRESSOR_FORMAT_RAW, G_ZLIB_COMPRESSOR_FORMAT_ZLIB,
G_ZLIB_COMPRESSOR_FORMAT_GZIP G_ZLIB_COMPRESSOR_FORMAT_GZIP,
G_ZLIB_COMPRESSOR_FORMAT_RAW
} GZlibCompressorFormat; } GZlibCompressorFormat;
G_END_DECLS G_END_DECLS

View File

@ -157,7 +157,15 @@ g_zlib_compressor_constructed (GObject *object)
MAX_WBITS + 16, 8, MAX_WBITS + 16, 8,
Z_DEFAULT_STRATEGY); Z_DEFAULT_STRATEGY);
} }
else else if (compressor->format == G_ZLIB_COMPRESSOR_FORMAT_RAW)
{
/* negative wbits for raw */
res = deflateInit2 (&compressor->zstream,
compressor->level, Z_DEFLATED,
-MAX_WBITS, 8,
Z_DEFAULT_STRATEGY);
}
else /* ZLIB */
res = deflateInit (&compressor->zstream, compressor->level); res = deflateInit (&compressor->zstream, compressor->level);
if (res == Z_MEM_ERROR ) if (res == Z_MEM_ERROR )
@ -183,7 +191,7 @@ g_zlib_compressor_class_init (GZlibCompressorClass *klass)
P_("compression format"), P_("compression format"),
P_("The format of the compressed data"), P_("The format of the compressed data"),
G_TYPE_ZLIB_COMPRESSOR_FORMAT, G_TYPE_ZLIB_COMPRESSOR_FORMAT,
G_ZLIB_COMPRESSOR_FORMAT_RAW, G_ZLIB_COMPRESSOR_FORMAT_ZLIB,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,

View File

@ -144,7 +144,12 @@ g_zlib_decompressor_constructed (GObject *object)
/* + 16 for gzip */ /* + 16 for gzip */
res = inflateInit2 (&decompressor->zstream, MAX_WBITS + 16); res = inflateInit2 (&decompressor->zstream, MAX_WBITS + 16);
} }
else else if (decompressor->format == G_ZLIB_COMPRESSOR_FORMAT_RAW)
{
/* Negative for gzip */
res = inflateInit2 (&decompressor->zstream, -MAX_WBITS);
}
else /* ZLIB */
res = inflateInit (&decompressor->zstream); res = inflateInit (&decompressor->zstream);
if (res == Z_MEM_ERROR ) if (res == Z_MEM_ERROR )
@ -170,7 +175,7 @@ g_zlib_decompressor_class_init (GZlibDecompressorClass *klass)
P_("compression format"), P_("compression format"),
P_("The format of the compressed data"), P_("The format of the compressed data"),
G_TYPE_ZLIB_COMPRESSOR_FORMAT, G_TYPE_ZLIB_COMPRESSOR_FORMAT,
G_ZLIB_COMPRESSOR_FORMAT_RAW, G_ZLIB_COMPRESSOR_FORMAT_ZLIB,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
} }

View File

@ -76,7 +76,7 @@ cat (GFile * file)
if (decompress) if (decompress)
{ {
GInputStream *old; GInputStream *old;
conv = (GConverter *)g_zlib_decompressor_new (gzip?G_ZLIB_COMPRESSOR_FORMAT_GZIP:G_ZLIB_COMPRESSOR_FORMAT_RAW); conv = (GConverter *)g_zlib_decompressor_new (gzip?G_ZLIB_COMPRESSOR_FORMAT_GZIP:G_ZLIB_COMPRESSOR_FORMAT_ZLIB);
old = in; old = in;
in = (GInputStream *) g_converter_input_stream_new (in, conv); in = (GInputStream *) g_converter_input_stream_new (in, conv);
g_object_unref (conv); g_object_unref (conv);
@ -108,7 +108,7 @@ cat (GFile * file)
if (compress) if (compress)
{ {
GInputStream *old; GInputStream *old;
conv = (GConverter *)g_zlib_compressor_new (gzip?G_ZLIB_COMPRESSOR_FORMAT_GZIP:G_ZLIB_COMPRESSOR_FORMAT_RAW, -1); conv = (GConverter *)g_zlib_compressor_new (gzip?G_ZLIB_COMPRESSOR_FORMAT_GZIP:G_ZLIB_COMPRESSOR_FORMAT_ZLIB, -1);
old = in; old = in;
in = (GInputStream *) g_converter_input_stream_new (in, conv); in = (GInputStream *) g_converter_input_stream_new (in, conv);
g_object_unref (conv); g_object_unref (conv);