HuntnGather – Diff between revs 2 and 5
?pathlinks?
Rev 2 | Rev 5 | |||
---|---|---|---|---|
Line 14... | Line 14... | |||
14 | #include <proto/dos.h> |
14 | #include <proto/dos.h> |
|
15 | #include <proto/exec.h> |
15 | #include <proto/exec.h> |
|
Line 16... | Line 16... | |||
16 | |
16 | |
|
Line 17... | Line 17... | |||
17 | #include "StringStack.h" |
17 | #include "StringStack.h" |
|
18 | |
18 | |
|
19 | #if defined ___AmigaOS___ |
19 | #if !defined ___HAVE_GETOPT___ |
|
Line -... | Line 20... | |||
- | 20 | #include "getopt.h" |
||
- | 21 | #endif |
||
- | 22 | |
||
- | 23 | #if defined ___AmigaOS___ |
||
- | 24 | #include <dos/dos.h> |
||
- | 25 | #include <dos/rdargs.h> |
||
- | 26 | #define TEMPLATE "Q=Quiet/S,D=Database/K,P=Path/A/F" |
||
- | 27 | #define OPT_QUIET 0 |
||
- | 28 | #define OPT_DATABASE 1 |
||
- | 29 | #define OPT_PATH 2 |
||
- | 30 | #define OPT_COUNT 3 |
||
- | 31 | LONG result[OPT_COUNT]; |
||
- | 32 | /*************************************************************************/ |
||
- | 33 | /* Version string used for querrying the program version. */ |
||
- | 34 | /*************************************************************************/ |
||
Line 20... | Line 35... | |||
20 | #include "getopt.h" |
35 | TEXT version_string[] = |
|
21 | #endif |
36 | "\0$VER: Gather 1.4 "__DATE__" by Wizardry and Steamworks"; |
|
22 | |
37 | #endif |
|
Line 30... | Line 45... | |||
30 | #endif |
45 | #endif |
|
Line 31... | Line 46... | |||
31 | |
46 | |
|
32 | #define MAX_MEM 262144 |
47 | #define MAX_MEM 262144 |
|
Line 33... | Line -... | |||
33 | #define DEFAULT_DATABASE_FILE "S:gather.db" |
- | ||
34 | |
- | ||
35 | /*************************************************************************/ |
- | ||
36 | /* Version string used for querrying the program version. */ |
- | ||
37 | /*************************************************************************/ |
- | ||
38 | TEXT version_string[] = |
- | ||
39 | "\0$VER: Gather 1.3 "__DATE__" by Wizardry and Steamworks"; |
48 | #define DEFAULT_DATABASE_FILE "S:gather.db" |
|
40 | |
49 | |
|
41 | typedef struct { |
50 | typedef struct { |
|
42 | unsigned int dirs; |
51 | unsigned int dirs; |
|
Line 639... | Line 648... | |||
639 | /* |
648 | /* |
|
640 | * |
649 | * |
|
641 | * Main entry point. |
650 | * Main entry point. |
|
642 | */ |
651 | */ |
|
643 | int main(int argc, char **argv) { |
652 | int main(int argc, char **argv) { |
|
- | 653 | #if defined ___AmigaOS___ |
||
- | 654 | struct RDArgs *rdargs; |
||
- | 655 | struct stat statPath; |
||
- | 656 | UBYTE *dbFile; |
||
- | 657 | UBYTE *argPath; |
||
- | 658 | |
||
- | 659 | dbFile = DEFAULT_DATABASE_FILE; |
||
- | 660 | argPath = NULL; |
||
- | 661 | if(rdargs = (struct RDArgs *) AllocDosObject(DOS_RDARGS, NULL)) { |
||
- | 662 | if(ReadArgs(TEMPLATE, result, rdargs) == NULL) { |
||
- | 663 | FreeArgs(rdargs); |
||
- | 664 | FreeDosObject(DOS_RDARGS, rdargs); |
||
- | 665 | return 1; |
||
- | 666 | } |
||
- | 667 | |
||
- | 668 | if(result[OPT_DATABASE] != NULL) { |
||
- | 669 | dbFile = (UBYTE *) result[OPT_DATABASE]; |
||
- | 670 | } |
||
- | 671 | |
||
- | 672 | if(result[OPT_QUIET]) { |
||
- | 673 | verbose = FALSE; |
||
- | 674 | } |
||
- | 675 | |
||
- | 676 | argPath = (UBYTE *) result[OPT_PATH]; |
||
- | 677 | |
||
- | 678 | FreeArgs(rdargs); |
||
- | 679 | FreeDosObject(DOS_RDARGS, rdargs); |
||
- | 680 | } |
||
- | 681 | |
||
- | 682 | stat(argPath, &statPath); |
||
- | 683 | if(!S_ISDIR(statPath.st_mode)) { |
||
- | 684 | fprintf(stderr, "Path '%s' is not a directory.\n", argPath); |
||
- | 685 | return 1; |
||
- | 686 | } |
||
- | 687 | |
||
- | 688 | if(verbose) { |
||
- | 689 | fprintf(stdout, "Gathering to database file: %s\n", dbFile); |
||
- | 690 | } |
||
- | 691 | |
||
- | 692 | Gather(dbFile, argPath); |
||
- | 693 | #else |
||
644 | int option; |
694 | int option; |
|
645 | char *dbFile; |
695 | char *dbFile; |
|
646 | struct stat path; |
696 | struct stat path; |
|
Line 647... | Line 697... | |||
647 | |
697 | |
|
Line 672... | Line 722... | |||
672 | return 1; |
722 | return 1; |
|
673 | } |
723 | } |
|
Line 674... | Line 724... | |||
674 | |
724 | |
|
675 | stat(argv[optind], &path); |
725 | stat(argv[optind], &path); |
|
676 | if(!S_ISDIR(path.st_mode)) { |
726 | if(!S_ISDIR(path.st_mode)) { |
|
677 | fprintf(stderr, "%s is not a directory.\n", argv[optind]); |
727 | fprintf(stderr, "Path '%s' is not a directory.\n", argv[optind]); |
|
678 | return 1; |
728 | return 1; |
|
Line 679... | Line 729... | |||
679 | } |
729 | } |
|
680 | |
730 | |
|
681 | if(verbose) { |
731 | if(verbose) { |
|
Line 682... | Line 732... | |||
682 | fprintf(stdout, "Gathering to database file: %s\n", dbFile); |
732 | fprintf(stdout, "Gathering to database file: %s\n", dbFile); |
|
683 | } |
733 | } |
|
- | 734 | |
||
Line 684... | Line 735... | |||
684 | |
735 | // Gather. |
|
685 | // Gather. |
736 | Gather(dbFile, argv[optind]); |