HuntnGather – Diff between revs 27 and 29
?pathlinks?
Rev 27 | Rev 29 | |||
---|---|---|---|---|
Line 3... | Line 3... | |||
3 | /////////////////////////////////////////////////////////////////////////// |
3 | /////////////////////////////////////////////////////////////////////////// |
|
Line 4... | Line 4... | |||
4 | |
4 | |
|
5 | #include <stdio.h> |
5 | #include <stdio.h> |
|
6 | #include <stdlib.h> |
6 | #include <stdlib.h> |
|
7 | #include <string.h> |
- | ||
8 | #include <dirent.h> |
7 | #include <string.h> |
|
9 | #include <ctype.h> |
8 | #include <ctype.h> |
|
10 | #if !defined ___AmigaOS___ |
9 | #if !defined ___AmigaOS___ |
|
- | 10 | #include <signal.h> |
||
- | 11 | #include <dirent.h> |
||
11 | #include <signal.h> |
12 | #include <sys/stat.h> |
|
Line 12... | Line -... | |||
12 | #endif |
- | ||
13 | |
13 | #endif |
|
14 | |
- | ||
Line 15... | Line 14... | |||
15 | #include <sys/types.h> |
14 | |
|
16 | #include <sys/stat.h> |
15 | #include <sys/types.h> |
|
17 | |
16 | |
|
18 | #if defined ___AmigaOS___ |
17 | #if defined ___AmigaOS___ |
|
Line 273... | Line 272... | |||
273 | fprintf(stdout, " \n"); |
272 | fprintf(stdout, " \n"); |
|
274 | fprintf(stdout, "(c) 2021 Wizardry and Steamworks, MIT. \n"); |
273 | fprintf(stdout, "(c) 2021 Wizardry and Steamworks, MIT. \n"); |
|
275 | } |
274 | } |
|
Line 276... | Line 275... | |||
276 | |
275 | |
|
- | 276 | int main(int argc, char **argv) { |
||
- | 277 | #if defined ___AmigaOS___ |
||
- | 278 | struct FileInfoBlock *FIB; |
||
- | 279 | BPTR lock; |
||
- | 280 | #else |
||
- | 281 | struct stat dirStat; |
||
277 | int main(int argc, char **argv) { |
282 | #endif |
|
278 | int option; |
283 | int option; |
|
279 | char *dbFile; |
- | ||
Line 280... | Line 284... | |||
280 | struct stat path; |
284 | char *dbFile; |
|
281 | |
285 | |
|
282 | // Bind handler to SIGINT. |
286 | // Bind handler to SIGINT. |
|
283 | #if !defined ___AmigaOS___ |
287 | #if !defined ___AmigaOS___ |
|
Line 302... | Line 306... | |||
302 | if(optind >= argc) { |
306 | if(optind >= argc) { |
|
303 | usage(argv[0]); |
307 | usage(argv[0]); |
|
304 | return 1; |
308 | return 1; |
|
305 | } |
309 | } |
|
Line -... | Line 310... | |||
- | 310 | |
||
- | 311 | #if defined ___AmigaOS___ |
||
- | 312 | if((lock = Lock(dbFile, ACCESS_READ)) == NULL) { |
||
- | 313 | fprintf(stderr, "Path '%s' is not accessible.\n", dbFile); |
||
- | 314 | return 1; |
||
- | 315 | } |
||
- | 316 | |
||
- | 317 | if((FIB = AllocDosObject(DOS_FIB, NULL)) == NULL) { |
||
- | 318 | fprintf(stderr, "Path '%s' file information block not accessible.\n", dbFile); |
||
- | 319 | UnLock(lock); |
||
- | 320 | return 1; |
||
- | 321 | } |
||
- | 322 | |
||
- | 323 | if(Examine(lock, FIB) == FALSE) { |
||
- | 324 | fprintf(stderr, "Path '%s' information unexaminable.\n", dbFile); |
||
- | 325 | FreeDosObject(DOS_FIB, FIB); |
||
- | 326 | UnLock(lock); |
||
- | 327 | return 1; |
||
- | 328 | } |
||
- | 329 | |
||
- | 330 | if(FIB->fib_DirEntryType > 0) { |
||
306 | |
331 | #else |
|
307 | stat(dbFile, &path); |
332 | stat(dbFile, &dirStat); |
|
- | 333 | if(!S_ISREG(dirStat.st_mode)) { |
||
308 | if(!S_ISREG(path.st_mode)) { |
334 | #endif |
|
309 | fprintf(stderr, "'%s' is not a file.\n", dbFile); |
335 | fprintf(stderr, "'%s' is not a file.\n", dbFile); |
|
310 | return 1; |
336 | return 1; |
|
Line -... | Line 337... | |||
- | 337 | } |
||
- | 338 | |
||
- | 339 | #if defined ___AmigaOS___ |
||
- | 340 | FreeDosObject(DOS_FIB, FIB); |
||
- | 341 | UnLock(lock); |
||
311 | } |
342 | #endif |
|
Line 312... | Line 343... | |||
312 | |
343 | |
|
313 | Hunt(dbFile, argv[optind]); |
344 | Hunt(dbFile, argv[optind]); |