HuntnGather – Diff between revs 33 and 37
?pathlinks?
Rev 33 | Rev 37 | |||
---|---|---|---|---|
Line 1005... | Line 1005... | |||
1005 | // Write "tmpLines" to temporary files in "tmpNames" from "dbFile". |
1005 | // Write "tmpLines" to temporary files in "tmpNames" from "dbFile". |
|
1006 | WriteTemporaryFiles(dbFile, tmpNames, tmpFiles, tmpLines, stats->lines); |
1006 | WriteTemporaryFiles(dbFile, tmpNames, tmpFiles, tmpLines, stats->lines); |
|
Line 1007... | Line 1007... | |||
1007 | |
1007 | |
|
1008 | // Sort the temporary files. |
1008 | // Sort the temporary files. |
|
1009 | for(i = 0; i < tmpFiles; ++i) { |
1009 | for(i = 0; i < tmpFiles; ++i) { |
|
1010 | tmpLines = CountFileLines(tmpNames[i]); |
1010 | // Twice the number of computed lines required should cover the last file. |
|
1011 | SortDatabase(tmpNames[i], tmpLines); |
1011 | SortDatabase(tmpNames[i], 2 * tmpLines); |
|
Line 1012... | Line 1012... | |||
1012 | } |
1012 | } |
|
1013 | |
1013 | |
|
Line 1110... | Line 1110... | |||
1110 | case 'h': |
1110 | case 'h': |
|
1111 | usage(argv[0]); |
1111 | usage(argv[0]); |
|
1112 | return 0; |
1112 | return 0; |
|
1113 | case '?': |
1113 | case '?': |
|
1114 | fprintf(stderr, "Invalid option %ct.\n", optopt); |
1114 | fprintf(stderr, "Invalid option %ct.\n", optopt); |
|
1115 | return 1; |
1115 | return 5; |
|
1116 | } |
1116 | } |
|
1117 | } |
1117 | } |
|
Line 1118... | Line 1118... | |||
1118 | |
1118 | |
|
1119 | if(operation == NONE) { |
1119 | if(operation == NONE) { |
|
1120 | usage(argv[0]); |
1120 | usage(argv[0]); |
|
1121 | return 1; |
1121 | return 5; |
|
Line 1122... | Line 1122... | |||
1122 | } |
1122 | } |
|
1123 | |
1123 | |
|
1124 | if(optind >= argc) { |
1124 | if(optind >= argc) { |
|
1125 | usage(argv[0]); |
1125 | usage(argv[0]); |
|
Line 1126... | Line 1126... | |||
1126 | return 1; |
1126 | return 5; |
|
1127 | } |
1127 | } |
|
1128 | |
1128 | |
|
1129 | // Go through all supplied arguments and add paths to search. |
1129 | // Go through all supplied arguments and add paths to search. |
|
1130 | if((paths = malloc((argc - optind) * sizeof(*paths))) == NULL) { |
1130 | if((paths = malloc((argc - optind) * sizeof(*paths))) == NULL) { |
|
Line 1131... | Line 1131... | |||
1131 | fprintf(stderr, "Memory allocation failure.\n"); |
1131 | fprintf(stderr, "Memory allocation failure.\n"); |
|
1132 | return 1; |
1132 | return 20; |
|
1133 | } |
1133 | } |
|
Line 1155... | Line 1155... | |||
1155 | } |
1155 | } |
|
Line 1156... | Line 1156... | |||
1156 | |
1156 | |
|
1157 | // Add the path to the array of paths. |
1157 | // Add the path to the array of paths. |
|
1158 | if((paths[count] = malloc((strlen(path) + 1) * sizeof(*paths[count]))) == NULL) { |
1158 | if((paths[count] = malloc((strlen(path) + 1) * sizeof(*paths[count]))) == NULL) { |
|
1159 | fprintf(stderr, "Memory allocation failure."); |
1159 | fprintf(stderr, "Memory allocation failure."); |
|
1160 | return 1; |
1160 | return 20; |
|
Line 1161... | Line 1161... | |||
1161 | } |
1161 | } |
|
1162 | |
1162 | |
|
Line 1168... | Line 1168... | |||
1168 | } |
1168 | } |
|
Line 1169... | Line 1169... | |||
1169 | |
1169 | |
|
1170 | if(count == 0) { |
1170 | if(count == 0) { |
|
1171 | fprintf(stderr, "No valid paths are available.\n"); |
1171 | fprintf(stderr, "No valid paths are available.\n"); |
|
1172 | free(paths); |
1172 | free(paths); |
|
1173 | return 1; |
1173 | return 5; |
|
Line 1174... | Line 1174... | |||
1174 | } |
1174 | } |
|
1175 | |
1175 | |
|
1176 | if(PROGRAM_VERBOSE) { |
1176 | if(PROGRAM_VERBOSE) { |
|
Line 1184... | Line 1184... | |||
1184 | switch(operation) { |
1184 | switch(operation) { |
|
1185 | case CREATE: |
1185 | case CREATE: |
|
1186 | if(PROGRAM_VERBOSE) { |
1186 | if(PROGRAM_VERBOSE) { |
|
1187 | fprintf(stdout, "Removing '%s' and creating a new database.\n", dbFile); |
1187 | fprintf(stdout, "Removing '%s' and creating a new database.\n", dbFile); |
|
1188 | } |
1188 | } |
|
1189 | if(RemoveFile(dbFile) == FALSE) { |
1189 | RemoveFile(dbFile); |
|
1190 | fprintf(stderr, "File '%s' could not be removed.\n", dbFile); |
- | ||
1191 | break; |
- | ||
1192 | } |
- | ||
1193 | case GATHER: |
1190 | case GATHER: |
|
1194 | if(PROGRAM_VERBOSE) { |
1191 | if(PROGRAM_VERBOSE) { |
|
1195 | fprintf(stdout, "Gathering files to database...\n"); |
1192 | fprintf(stdout, "Gathering files to database...\n"); |
|
1196 | } |
1193 | } |
|
1197 | GatherDatabaseFiles(dbFile, paths, count); |
1194 | GatherDatabaseFiles(dbFile, paths, count); |
|
Line 1202... | Line 1199... | |||
1202 | } |
1199 | } |
|
1203 | RemoveDatabaseFiles(dbFile, paths, count); |
1200 | RemoveDatabaseFiles(dbFile, paths, count); |
|
1204 | break; |
1201 | break; |
|
1205 | default: |
1202 | default: |
|
1206 | fprintf(stderr, "Unknown operation.\n"); |
1203 | fprintf(stderr, "Unknown operation.\n"); |
|
- | 1204 | #if defined ___AmigaOS___ |
||
- | 1205 | CloseLocale(locale); |
||
- | 1206 | #endif |
||
- | 1207 | |
||
- | 1208 | free(paths); |
||
1207 | break; |
1209 | return 5; |
|
1208 | } |
1210 | } |
|
Line 1209... | Line 1211... | |||
1209 | |
1211 | |
|
1210 | #if defined ___AmigaOS___ |
1212 | #if defined ___AmigaOS___ |
|
1211 | CloseLocale(locale); |
1213 | CloseLocale(locale); |