changeset 1027:d29058e93799

Add option for setting the zlib compression level.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 01 Mar 2015 16:08:36 +0200
parents 16e63811d0c2
children 99522b9fa99e
files tools/packed.c
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/packed.c	Sun Mar 01 16:07:45 2015 +0200
+++ b/tools/packed.c	Sun Mar 01 16:08:36 2015 +0200
@@ -36,6 +36,7 @@
 
 char * optPackFilename = NULL;
 BOOL   optCompress = TRUE;
+int    optCompressLevel = Z_BEST_COMPRESSION;
 int    optCommand = CMD_NONE;
 int    optDefResFlags = 0;
 
@@ -49,6 +50,7 @@
     {  4, 'l', "list",        "List files in PACK", OPT_NONE },
     {  5, 'e', "extract",     "Extract files from PACK", OPT_NONE },
     {  6, 'n', "nocompress",  "No compression / decompression", OPT_NONE },
+    { 10, 'C', "level",       "Set zlib compression level 1-9", OPT_ARGREQ },
     {  7, 'v', "verbose",     "Increase verbosity", OPT_NONE },
     {  8, 'f', "resflags",    "Set default resource flags (-f 0xff)", OPT_ARGREQ },
     {  9, 'x', "exclude",     "Exclude name/glob pattern from add", OPT_ARGREQ },
@@ -130,6 +132,15 @@
             }
             break;
 
+        case 10:
+            optCompressLevel = atoi(optArg);
+            if (optCompressLevel < 1 || optCompressLevel > 9)
+            {
+                dmErrorMsg("Invalid compression level argument '%s', must be 1 .. 9.\n", optArg);
+                return FALSE;
+            }
+            break;
+
         default:
             dmErrorMsg("Unknown argument '%s'.\n", currArg);
             return FALSE;
@@ -651,7 +662,7 @@
                 DMPackEntry *node = NULL;
                 int res = dmPackAddFile(pack, srcFilenames[i],
                     optDefResFlags, optCompress,
-                    Z_DEFAULT_COMPRESSION, &node);
+                    optCompressLevel, &node);
 
                 if (res != DMERR_OK)
                 {