Mercurial > hg > dmlib
comparison tools/packed.c @ 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 |
comparison
equal
deleted
inserted
replaced
1026:16e63811d0c2 | 1027:d29058e93799 |
---|---|
34 char * srcFilenames[SET_MAX_FILES]; | 34 char * srcFilenames[SET_MAX_FILES]; |
35 char * excFilenames[SET_MAX_FILES]; | 35 char * excFilenames[SET_MAX_FILES]; |
36 | 36 |
37 char * optPackFilename = NULL; | 37 char * optPackFilename = NULL; |
38 BOOL optCompress = TRUE; | 38 BOOL optCompress = TRUE; |
39 int optCompressLevel = Z_BEST_COMPRESSION; | |
39 int optCommand = CMD_NONE; | 40 int optCommand = CMD_NONE; |
40 int optDefResFlags = 0; | 41 int optDefResFlags = 0; |
41 | 42 |
42 | 43 |
43 static const DMOptArg optList[] = | 44 static const DMOptArg optList[] = |
47 { 2, 'c', "create", "Create and add files to PACK", OPT_NONE }, | 48 { 2, 'c', "create", "Create and add files to PACK", OPT_NONE }, |
48 { 3, 'a', "add", "Add files to PACK", OPT_NONE }, | 49 { 3, 'a', "add", "Add files to PACK", OPT_NONE }, |
49 { 4, 'l', "list", "List files in PACK", OPT_NONE }, | 50 { 4, 'l', "list", "List files in PACK", OPT_NONE }, |
50 { 5, 'e', "extract", "Extract files from PACK", OPT_NONE }, | 51 { 5, 'e', "extract", "Extract files from PACK", OPT_NONE }, |
51 { 6, 'n', "nocompress", "No compression / decompression", OPT_NONE }, | 52 { 6, 'n', "nocompress", "No compression / decompression", OPT_NONE }, |
53 { 10, 'C', "level", "Set zlib compression level 1-9", OPT_ARGREQ }, | |
52 { 7, 'v', "verbose", "Increase verbosity", OPT_NONE }, | 54 { 7, 'v', "verbose", "Increase verbosity", OPT_NONE }, |
53 { 8, 'f', "resflags", "Set default resource flags (-f 0xff)", OPT_ARGREQ }, | 55 { 8, 'f', "resflags", "Set default resource flags (-f 0xff)", OPT_ARGREQ }, |
54 { 9, 'x', "exclude", "Exclude name/glob pattern from add", OPT_ARGREQ }, | 56 { 9, 'x', "exclude", "Exclude name/glob pattern from add", OPT_ARGREQ }, |
55 }; | 57 }; |
56 | 58 |
128 SET_MAX_FILES); | 130 SET_MAX_FILES); |
129 return FALSE; | 131 return FALSE; |
130 } | 132 } |
131 break; | 133 break; |
132 | 134 |
135 case 10: | |
136 optCompressLevel = atoi(optArg); | |
137 if (optCompressLevel < 1 || optCompressLevel > 9) | |
138 { | |
139 dmErrorMsg("Invalid compression level argument '%s', must be 1 .. 9.\n", optArg); | |
140 return FALSE; | |
141 } | |
142 break; | |
143 | |
133 default: | 144 default: |
134 dmErrorMsg("Unknown argument '%s'.\n", currArg); | 145 dmErrorMsg("Unknown argument '%s'.\n", currArg); |
135 return FALSE; | 146 return FALSE; |
136 } | 147 } |
137 | 148 |
649 if (!dmCheckExcluded(srcFilenames[i])) | 660 if (!dmCheckExcluded(srcFilenames[i])) |
650 { | 661 { |
651 DMPackEntry *node = NULL; | 662 DMPackEntry *node = NULL; |
652 int res = dmPackAddFile(pack, srcFilenames[i], | 663 int res = dmPackAddFile(pack, srcFilenames[i], |
653 optDefResFlags, optCompress, | 664 optDefResFlags, optCompress, |
654 Z_DEFAULT_COMPRESSION, &node); | 665 optCompressLevel, &node); |
655 | 666 |
656 if (res != DMERR_OK) | 667 if (res != DMERR_OK) |
657 { | 668 { |
658 dmPrint(1, "%-32s [ERROR:%d]\n", | 669 dmPrint(1, "%-32s [ERROR:%d]\n", |
659 srcFilenames[i], res); | 670 srcFilenames[i], res); |