Mercurial > hg > dmlib
annotate tools/packed.c @ 871:fc272f5f2d15
Make value type of dmGetIntVal() unsigned.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 03 Feb 2015 20:27:12 +0200 |
parents | daebbf28953d |
children | ffdae9cd81de |
rev | line source |
---|---|
0 | 1 /* |
2 * PACKed - PACKfile EDitor | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2011 Tecnic Software productions (TNSP) | |
5 */ | |
6 #include "dmlib.h" | |
7 #include "dmargs.h" | |
8 #include "dmpack.h" | |
9 #include "dmpackutil.h" | |
115
23e03defa759
Prettify pack content listing output.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
10 #include "dmres.h" |
285
245b15cd1919
Don't link libSDL uselessly to utilities that do not actually use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
211
diff
changeset
|
11 #include "dmmutex.h" |
0 | 12 #include <errno.h> |
13 | |
14 #define SET_MAX_FILES (4096) | |
15 #define SET_DEFAULT_PACK "data.pak" | |
16 | |
17 enum | |
18 { | |
19 CMD_NONE = 0, | |
20 CMD_CREATE, | |
21 CMD_ADD, | |
22 CMD_LIST, | |
23 CMD_EXTRACT | |
24 } DCOMMAND; | |
25 | |
26 enum | |
27 { | |
28 PACK_EXTRACTED = 0x0001, | |
29 }; | |
30 | |
752
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
31 int nsrcFilenames = 0, nexcFilenames = 0; |
0 | 32 char * srcFilenames[SET_MAX_FILES]; |
752
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
33 char * excFilenames[SET_MAX_FILES]; |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
34 |
0 | 35 char * optPackFilename = NULL; |
36 BOOL optCompress = TRUE; | |
37 int optCommand = CMD_NONE; | |
38 int optDefResFlags = 0; | |
39 | |
40 | |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
41 static const DMOptArg optList[] = |
0 | 42 { |
43 { 0, '?', "help", "Show this help", OPT_NONE }, | |
44 { 1, 'p', "pack", "Set pack filename (default: " SET_DEFAULT_PACK ")", OPT_ARGREQ }, | |
45 { 2, 'c', "create", "Create and add files to PACK", OPT_NONE }, | |
46 { 3, 'a', "add", "Add files to PACK", OPT_NONE }, | |
47 { 4, 'l', "list", "List files in PACK", OPT_NONE }, | |
48 { 5, 'e', "extract", "Extract files from PACK", OPT_NONE }, | |
49 { 6, 'n', "nocompress", "No compression", OPT_NONE }, | |
50 { 7, 'v', "verbose", "Increase verbosity", OPT_NONE }, | |
51 { 8, 'f', "resflags", "Set default resource flags (-f 0xff)", OPT_ARGREQ }, | |
752
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
52 { 9, 'x', "exclude", "Exclude name/glob pattern from add", OPT_ARGREQ }, |
0 | 53 }; |
54 | |
55 static const int optListN = sizeof(optList) / sizeof(optList[0]); | |
56 | |
57 | |
58 void argShowHelp() | |
59 { | |
117
b56ce9981d79
Correct help of 'packed' utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
115
diff
changeset
|
60 dmPrintBanner(stdout, dmProgName, "[options] [-p <packfilename>] [filename[s]]"); |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
61 dmArgsPrintHelp(stdout, optList, optListN, 0); |
0 | 62 fprintf(stdout, |
63 "\n" | |
64 "Examples:\n" | |
65 "$ %s -p test.pak -l -- list files in test.pak\n" | |
66 "$ %s -a foobar.jpg -- add foobar.jpg in " SET_DEFAULT_PACK "\n" | |
752
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
67 "$ %s -e foobar.jpg -- extract foobar.jpg from " SET_DEFAULT_PACK "\n", |
0 | 68 dmProgName, dmProgName, dmProgName); |
69 } | |
70 | |
71 | |
72 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) | |
73 { | |
74 (void) optArg; | |
75 switch (optN) | |
76 { | |
211 | 77 case 0: |
78 argShowHelp(); | |
79 exit(0); | |
80 break; | |
0 | 81 |
211 | 82 case 1: |
83 optPackFilename = optArg; | |
84 break; | |
85 case 2: | |
86 optCommand = CMD_CREATE; | |
87 break; | |
88 case 3: | |
89 optCommand = CMD_ADD; | |
90 break; | |
91 case 4: | |
92 optCommand = CMD_LIST; | |
93 break; | |
94 case 5: | |
95 optCommand = CMD_EXTRACT; | |
96 break; | |
0 | 97 |
211 | 98 case 6: |
99 optCompress = FALSE; | |
100 break; | |
0 | 101 |
211 | 102 case 7: |
103 dmVerbosity++; | |
104 break; | |
0 | 105 |
211 | 106 case 8: |
0 | 107 { |
871
fc272f5f2d15
Make value type of dmGetIntVal() unsigned.
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
108 unsigned int i; |
211 | 109 if (!dmGetIntVal(optArg, &i)) |
110 { | |
111 dmError("Invalid flags value '%s'.\n", optArg); | |
112 return FALSE; | |
113 } | |
114 optDefResFlags = i; | |
0 | 115 } |
211 | 116 break; |
752
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
117 |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
118 case 9: |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
119 if (nexcFilenames < SET_MAX_FILES) |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
120 { |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
121 excFilenames[nsrcFilenames] = currArg; |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
122 nexcFilenames++; |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
123 } |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
124 else |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
125 { |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
126 dmError("Maximum number of exclusion patterns (%d) exceeded!\n", |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
127 SET_MAX_FILES); |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
128 return FALSE; |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
129 } |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
130 break; |
0 | 131 |
211 | 132 default: |
133 dmError("Unknown argument '%s'.\n", currArg); | |
134 return FALSE; | |
0 | 135 } |
136 | |
137 return TRUE; | |
138 } | |
139 | |
140 | |
141 BOOL argHandleFile(char *currArg) | |
142 { | |
143 if (nsrcFilenames < SET_MAX_FILES) | |
144 { | |
145 srcFilenames[nsrcFilenames] = currArg; | |
146 nsrcFilenames++; | |
147 } | |
148 else | |
149 { | |
314 | 150 dmError("Maximum number of input files (%d) exceeded!\n", |
0 | 151 SET_MAX_FILES); |
152 return FALSE; | |
153 } | |
154 return TRUE; | |
155 } | |
156 | |
157 | |
158 /* Compare a string to a pattern. Case-SENSITIVE version. | |
159 * The matching pattern can consist of any normal characters plus | |
160 * wildcards ? and *. "?" matches any character and "*" matches | |
161 * any number of characters. | |
162 */ | |
163 BOOL dm_strmatch(const char *str, const char *pattern) | |
164 { | |
165 BOOL didMatch = TRUE, isAnyMode = FALSE, isEnd = FALSE; | |
166 const char *tmpPattern = NULL; | |
167 | |
168 // Check given pattern and string | |
169 if (str == NULL || pattern == NULL) | |
170 return FALSE; | |
171 | |
172 // Start comparision | |
173 do { | |
174 didMatch = FALSE; | |
175 switch (*pattern) | |
176 { | |
177 case '?': | |
178 // Any single character matches | |
179 if (*str) | |
180 { | |
181 didMatch = TRUE; | |
182 pattern++; | |
183 str++; | |
184 } | |
185 break; | |
186 | |
187 case '*': | |
188 didMatch = TRUE; | |
189 pattern++; | |
190 if (!*pattern) | |
191 isEnd = TRUE; | |
192 isAnyMode = TRUE; | |
193 tmpPattern = pattern; | |
194 break; | |
195 | |
196 case 0: | |
197 if (isAnyMode) | |
198 { | |
199 if (*str) | |
200 str++; | |
201 else | |
202 isEnd = TRUE; | |
203 } | |
204 else | |
205 { | |
206 if (*str) | |
207 { | |
208 if (tmpPattern) | |
209 { | |
210 isAnyMode = TRUE; | |
211 pattern = tmpPattern; | |
212 } | |
213 else | |
214 didMatch = FALSE; | |
215 } | |
216 else | |
217 isEnd = TRUE; | |
218 } | |
219 break; | |
220 default: | |
221 if (isAnyMode) | |
222 { | |
223 if (*pattern == *str) | |
224 { | |
225 isAnyMode = FALSE; | |
226 didMatch = TRUE; | |
227 } | |
228 else | |
229 { | |
230 if (*str) | |
231 { | |
232 didMatch = TRUE; | |
233 str++; | |
234 } | |
235 } | |
236 } | |
237 else | |
238 { | |
239 if (*pattern == *str) | |
240 { | |
241 didMatch = TRUE; | |
242 if (*pattern) | |
243 pattern++; | |
244 if (*str) | |
245 str++; | |
246 } | |
247 else | |
248 { | |
249 if (tmpPattern) | |
250 { | |
251 didMatch = TRUE; | |
252 isAnyMode = TRUE; | |
253 pattern = tmpPattern; | |
254 } | |
255 } | |
256 } | |
257 | |
258 if (!*str && !*pattern) | |
259 isEnd = TRUE; | |
260 break; | |
261 | |
262 } // switch | |
263 | |
264 } while (didMatch && !isEnd); | |
265 | |
266 return didMatch; | |
267 } | |
268 | |
269 | |
752
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
270 BOOL dmCheckExcluded(const char *filename) |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
271 { |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
272 int i; |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
273 for (i = 0; i < nexcFilenames; i++) |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
274 { |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
275 if (dm_strmatch(filename, excFilenames[i])) |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
276 return TRUE; |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
277 } |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
278 return FALSE; |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
279 } |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
280 |
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
281 |
0 | 282 int main(int argc, char *argv[]) |
283 { | |
284 int i, res = 0; | |
285 DMPackFile *pack = NULL; | |
286 | |
31
7ad2c6b57932
This ugly trick won't work under MinGW, so disable it there.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
287 #ifndef __WIN32 |
0 | 288 stderr = stdout; |
31
7ad2c6b57932
This ugly trick won't work under MinGW, so disable it there.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
289 #endif |
0 | 290 |
291 // Parse arguments | |
752
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
292 dmInitProg("packed", "Pack File Editor", "0.5", NULL, NULL); |
0 | 293 dmVerbosity = 1; |
294 | |
295 if (!dmArgsProcess(argc, argv, optList, optListN, | |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
296 argHandleOpt, argHandleFile, OPTH_BAILOUT)) |
0 | 297 exit(1); |
298 | |
299 // Check PACK filename | |
300 if (optPackFilename == NULL) | |
301 optPackFilename = SET_DEFAULT_PACK; | |
302 | |
303 if (optCommand == CMD_NONE) | |
304 { | |
305 argShowHelp(); | |
306 dmError("Nothing to do.\n"); | |
307 exit(0); | |
308 return 0; | |
309 } | |
310 | |
311 dmMsg(1, "Processing %s ...\n", optPackFilename); | |
312 | |
313 // Execute command | |
314 switch (optCommand) | |
315 { | |
316 case CMD_CREATE: | |
317 case CMD_ADD: | |
318 switch (optCommand) | |
319 { | |
320 case CMD_CREATE: | |
321 dmMsg(1, "Creating new PACK\n"); | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
322 res = dmPackCreate(optPackFilename, &pack); |
0 | 323 break; |
324 | |
325 case CMD_ADD: | |
326 dmMsg(1, "Opening existing PACK\n"); | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
327 res = dmPackOpen(optPackFilename, &pack, FALSE); |
0 | 328 break; |
329 } | |
330 | |
331 // Add files into PACK | |
332 if (res == DMERR_OK) | |
333 { | |
752
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
334 dmMsg(1, "Adding files...\n"); |
0 | 335 |
336 for (i = 0; i < nsrcFilenames; i++) | |
752
2b9dd22f01e9
Improve packed by adding file exclusion option.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
337 if (!dmCheckExcluded(srcFilenames[i])) |
0 | 338 { |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
339 DMPackEntry *node = NULL; |
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
340 int res = dmPackAddFile(pack, srcFilenames[i], optCompress, optDefResFlags, &node); |
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
341 |
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
342 if (res != DMERR_OK) |
0 | 343 { |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
344 dmPrint(1, "%-32s [ERROR:%d]\n", |
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
345 srcFilenames[i], res); |
0 | 346 } |
347 else | |
348 { | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
349 dmPrint(1, "%-32s ['%s', s=%d, c=%d, o=%ld, f=0x%04x]\n", |
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
350 srcFilenames[i], node->filename, |
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
351 node->size, node->length, node->offset, node->flags); |
0 | 352 } |
353 } | |
354 | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
355 dmMsg(1, "w=%d\n", dmPackWrite(pack)); |
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
356 dmMsg(1, "c=%d\n", dmPackClose(pack)); |
0 | 357 } |
358 else | |
359 { | |
314 | 360 dmError("Could not open packfile, error #%d: %s\n", res, |
0 | 361 dmErrorStr(res)); |
362 } | |
363 break; | |
364 | |
365 case CMD_LIST: | |
366 // List files in PACK | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
367 res = dmPackOpen(optPackFilename, &pack, TRUE); |
0 | 368 if (res == DMERR_OK) |
369 { | |
370 DMPackEntry *node; | |
371 for (i = 0, node = pack->entries; node; i++) | |
372 node = node->next; | |
373 dmMsg(1, "%d files total\n", i); | |
374 | |
115
23e03defa759
Prettify pack content listing output.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
375 dmPrint(0, "%-32s | %8s | %8s | %8s | %s\n", |
23e03defa759
Prettify pack content listing output.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
376 "Name", "Size", "CSize", "Offset", "ResFlags"); |
23e03defa759
Prettify pack content listing output.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
377 |
0 | 378 for (node = pack->entries; node != NULL; node = node->next) |
379 { | |
380 BOOL match; | |
381 | |
382 // Check for matches | |
383 if (nsrcFilenames > 0) | |
384 { | |
385 match = FALSE; | |
386 for (i = 0; i < nsrcFilenames && !match; i++) | |
387 { | |
388 match = dm_strmatch(node->filename, srcFilenames[i]); | |
389 } | |
390 } | |
391 else | |
392 match = TRUE; | |
393 | |
394 if (match) | |
395 { | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
396 dmPrint(0, "%-32s | %8d | %8d | %08x | %04x\n", |
115
23e03defa759
Prettify pack content listing output.
Matti Hamalainen <ccr@tnsp.org>
parents:
31
diff
changeset
|
397 node->filename, node->size, node->length, |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
398 node->offset, node->flags); |
0 | 399 } |
400 } | |
401 | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
402 dmMsg(1, "c=%d\n", dmPackClose(pack)); |
0 | 403 } |
404 else | |
314 | 405 dmError("Could not open packfile, error #%d: %s\n", res, |
0 | 406 dmErrorStr(res)); |
407 break; | |
408 | |
409 case CMD_EXTRACT: | |
410 // Extract files from PACK | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
411 res = dmPackOpen(optPackFilename, &pack, TRUE); |
0 | 412 if (res == DMERR_OK) |
413 { | |
414 DMPackEntry *node; | |
415 FILE *resFile = fopen(DMRES_RES_FILE, "w"); | |
416 if (resFile == NULL) | |
417 { | |
314 | 418 dmError("Could not create resource output file '%s' #%d: %s\n", |
0 | 419 DMRES_RES_FILE, errno, strerror(errno)); |
420 } | |
421 | |
422 for (node = pack->entries; node != NULL; node = node->next) | |
423 { | |
424 BOOL match; | |
425 | |
426 // Check for matches | |
427 if (nsrcFilenames > 0) | |
428 { | |
429 match = FALSE; | |
430 for (i = 0; (i < nsrcFilenames) && !match; i++) | |
431 { | |
432 match = dm_strmatch(node->filename, srcFilenames[i]); | |
433 } | |
434 } | |
435 else | |
436 match = TRUE; | |
437 | |
438 if (match && (node->privFlags & PACK_EXTRACTED) == 0) | |
439 { | |
440 // Mark as done | |
441 node->privFlags |= PACK_EXTRACTED; | |
442 | |
443 // Print one entry | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
444 dmPrint(0, "Extracting: %-32s [siz=%d, cmp=%d, offs=0x%08x, flags=0x%04x]\n", |
0 | 445 node->filename, node->size, node->length, |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
446 node->offset, node->flags); |
0 | 447 |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
448 dmPackExtractFile(pack, node); |
0 | 449 } |
450 } | |
451 | |
721
bb14d7907eb2
Rename many pack & resource handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
452 dmMsg(1, "c=%d\n", dmPackClose(pack)); |
0 | 453 |
454 if (resFile != NULL) | |
455 fclose(resFile); | |
456 } | |
457 else | |
314 | 458 dmError("Could not open packfile, error #%d: %s\n", res, |
0 | 459 dmErrorStr(res)); |
460 break; | |
461 | |
462 } | |
463 | |
464 return 0; | |
465 } |