HuntnGather – Diff between revs 44 and 46
?pathlinks?
Rev 44 | Rev 46 | |||
---|---|---|---|---|
Line 28... | Line 28... | |||
28 | |
28 | |
|
29 | #if !defined ___HAVE_GETOPT___ |
29 | #if !defined ___HAVE_GETOPT___ |
|
30 | #include "/shared/getopt.h" |
30 | #include "/shared/getopt.h" |
|
Line 31... | Line 31... | |||
31 | #endif |
31 | #endif |
|
32 | |
32 | |
|
Line 33... | Line 33... | |||
33 | #include "StringStack.h" |
33 | #include "stack.h" |
|
Line 34... | Line 34... | |||
34 | #include "/shared/utilities.h" |
34 | #include "/shared/utilities.h" |
|
35 | |
35 | |
|
36 | #define PROGRAM_VERSION "1.7.5" |
36 | #define PROGRAM_VERSION "1.7.6" |
|
37 | |
37 | |
|
Line 279... | Line 279... | |||
279 | BPTR lock; |
279 | BPTR lock; |
|
280 | #else |
280 | #else |
|
281 | DIR *dir; |
281 | DIR *dir; |
|
282 | struct dirent *entry; |
282 | struct dirent *entry; |
|
283 | #endif |
283 | #endif |
|
284 | stringStack *stack; |
284 | stack *stack; |
|
285 | dbStats *stats = NULL; |
285 | dbStats *stats = NULL; |
|
286 | int i; |
286 | int i; |
|
287 | char *path; |
287 | char *path; |
|
288 | char *sub; |
288 | char *sub; |
|
Line 315... | Line 315... | |||
315 | stats->files = 0; |
315 | stats->files = 0; |
|
316 | stats->lines = 0; |
316 | stats->lines = 0; |
|
317 | stats->size = 0; |
317 | stats->size = 0; |
|
Line 318... | Line 318... | |||
318 | |
318 | |
|
319 | // Push the first path onto the stack. |
319 | // Push the first path onto the stack. |
|
320 | stack = stringStackCreate((unsigned int)paths->length); |
320 | stack = stackCreate((unsigned int)paths->length); |
|
321 | for(i = 0; PROGRAM_RUN && i < paths->length; ++i) { |
321 | for(i = 0; PROGRAM_RUN && i < paths->length; ++i) { |
|
- | 322 | fprintf(stdout, "Pushing '%s'\n", (char *)paths->array[i]); |
||
322 | stringStackPush(stack, paths->array[i]); |
323 | stackPush(stack, paths->array[i], (strlen(paths->array[i]) + 1) * sizeof(char)); |
|
Line 323... | Line 324... | |||
323 | } |
324 | } |
|
324 | |
325 | |
|
325 | while(PROGRAM_RUN && !stringStackIsEmpty(stack)) { |
326 | while(PROGRAM_RUN && !stackIsEmpty(stack)) { |
|
326 | #if defined ___AmigaOS___ |
327 | #if defined ___AmigaOS___ |
|
327 | // Check if CTRL+C was pressed and abort the program. |
328 | // Check if CTRL+C was pressed and abort the program. |
|
328 | if(SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) { |
329 | if(SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) { |
|
329 | PROGRAM_RUN = FALSE; |
330 | PROGRAM_RUN = FALSE; |
|
330 | continue; |
331 | continue; |
|
331 | } |
332 | } |
|
332 | #endif |
333 | #endif |
|
333 | if((path = stringStackPop(stack)) == NULL) { |
334 | if((path = (char *)stackPop(stack)) == NULL) { |
|
Line 334... | Line 335... | |||
334 | break; |
335 | break; |
|
335 | } |
336 | } |
|
Line 391... | Line 392... | |||
391 | FIB = NULL; |
392 | FIB = NULL; |
|
392 | UnLock(lock); |
393 | UnLock(lock); |
|
393 | #else |
394 | #else |
|
394 | closedir(dir); |
395 | closedir(dir); |
|
395 | #endif |
396 | #endif |
|
396 | |
- | ||
397 | free(path); |
397 | free(path); |
|
398 | path = NULL; |
398 | path = NULL; |
|
Line 399... | Line 399... | |||
399 | |
399 | |
|
400 | stringStackDestroy(stack); |
400 | stackDestroy(stack); |
|
401 | #if defined ___AsyncIO___ |
401 | #if defined ___AsyncIO___ |
|
402 | CloseAsync(fp); |
402 | CloseAsync(fp); |
|
403 | #else |
403 | #else |
|
404 | fclose(fp); |
404 | fclose(fp); |
|
Line 423... | Line 423... | |||
423 | FIB = NULL; |
423 | FIB = NULL; |
|
424 | UnLock(lock); |
424 | UnLock(lock); |
|
425 | #else |
425 | #else |
|
426 | closedir(dir); |
426 | closedir(dir); |
|
427 | #endif |
427 | #endif |
|
428 | |
- | ||
429 | free(path); |
428 | free(path); |
|
430 | path = NULL; |
429 | path = NULL; |
|
Line 431... | Line 430... | |||
431 | |
430 | |
|
432 | stringStackDestroy(stack); |
431 | stackDestroy(stack); |
|
433 | #if defined ___AsyncIO___ |
432 | #if defined ___AsyncIO___ |
|
434 | CloseAsync(fp); |
433 | CloseAsync(fp); |
|
435 | #else |
434 | #else |
|
436 | fclose(fp); |
435 | fclose(fp); |
|
Line 459... | Line 458... | |||
459 | stats->dirs, |
458 | stats->dirs, |
|
460 | stats->files); |
459 | stats->files); |
|
461 | } |
460 | } |
|
462 | break; |
461 | break; |
|
463 | case DIRECTORY: |
462 | case DIRECTORY: |
|
464 | stringStackPush(stack, sub); |
463 | stackPush(stack, sub, (strlen(sub) + 1) * sizeof(char)); |
|
Line 465... | Line 464... | |||
465 | |
464 | |
|
Line 466... | Line 465... | |||
466 | ++stats->dirs; |
465 | ++stats->dirs; |
|
467 | |
466 | |
|
Line 529... | Line 528... | |||
529 | |
528 | |
|
530 | if(PROGRAM_VERBOSE) { |
529 | if(PROGRAM_VERBOSE) { |
|
531 | fprintf(stdout, "\n"); |
530 | fprintf(stdout, "\n"); |
|
Line 532... | Line 531... | |||
532 | } |
531 | } |
|
Line 533... | Line 532... | |||
533 | |
532 | |
|
534 | stringStackDestroy(stack); |
533 | stackDestroy(stack); |
|
535 | |
534 | |
|
536 | #if defined ___AsyncIO___ |
535 | #if defined ___AsyncIO___ |