if (compression != 0)
{
#ifdef HAVE_LIBZ
- char mode_compression[32];
+ if (compression != Z_DEFAULT_COMPRESSION)
+ {
+ /* user has specified a compression level, so tell zlib to use it */
+ char mode_compression[32];
+
+ snprintf(mode_compression, sizeof(mode_compression), "%s%d",
+ mode, compression);
+ fp->compressedfp = gzopen(path, mode_compression);
+ }
+ else
+ {
+ /* don't specify a level, just use the zlib default */
+ fp->compressedfp = gzopen(path, mode);
+ }
- snprintf(mode_compression, sizeof(mode_compression), "%s%d",
- mode, compression);
- fp->compressedfp = gzopen(path, mode_compression);
fp->uncompressedfp = NULL;
if (fp->compressedfp == NULL)
{
ctx->hasSeek = checkSeek(ctx->tarFH);
- if (AH->compression < 0 || AH->compression > 9)
- AH->compression = Z_DEFAULT_COMPRESSION;
-
- /* Don't compress into tar files unless asked to do so */
- if (AH->compression == Z_DEFAULT_COMPRESSION)
- AH->compression = 0;
-
/*
* We don't support compression because reading the files back is not
* possible since gzdopen uses buffered IO which totally screws file
case 'Z': /* Compression Level */
compressLevel = atoi(optarg);
+ if (compressLevel < 0 || compressLevel > 9)
+ {
+ write_msg(NULL, "compression level must be in range 0..9\n");
+ exit_nicely(1);
+ }
break;
case 0: