HuntnGather
/trunk/HuntnGather/Hunt/Hunt.c |
@@ -5,15 +5,14 @@ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <dirent.h> |
#include <ctype.h> |
#if !defined ___AmigaOS___ |
#include <signal.h> |
#include <dirent.h> |
#include <sys/stat.h> |
#endif |
|
|
#include <sys/types.h> |
#include <sys/stat.h> |
|
#if defined ___AmigaOS___ |
#include <proto/dos.h> |
@@ -275,9 +274,14 @@ |
} |
|
int main(int argc, char **argv) { |
#if defined ___AmigaOS___ |
struct FileInfoBlock *FIB; |
BPTR lock; |
#else |
struct stat dirStat; |
#endif |
int option; |
char *dbFile; |
struct stat path; |
|
// Bind handler to SIGINT. |
#if !defined ___AmigaOS___ |
@@ -304,12 +308,39 @@ |
return 1; |
} |
|
stat(dbFile, &path); |
if(!S_ISREG(path.st_mode)) { |
#if defined ___AmigaOS___ |
if((lock = Lock(dbFile, ACCESS_READ)) == NULL) { |
fprintf(stderr, "Path '%s' is not accessible.\n", dbFile); |
return 1; |
} |
|
if((FIB = AllocDosObject(DOS_FIB, NULL)) == NULL) { |
fprintf(stderr, "Path '%s' file information block not accessible.\n", dbFile); |
UnLock(lock); |
return 1; |
} |
|
if(Examine(lock, FIB) == FALSE) { |
fprintf(stderr, "Path '%s' information unexaminable.\n", dbFile); |
FreeDosObject(DOS_FIB, FIB); |
UnLock(lock); |
return 1; |
} |
|
if(FIB->fib_DirEntryType > 0) { |
#else |
stat(dbFile, &dirStat); |
if(!S_ISREG(dirStat.st_mode)) { |
#endif |
fprintf(stderr, "'%s' is not a file.\n", dbFile); |
return 1; |
} |
|
#if defined ___AmigaOS___ |
FreeDosObject(DOS_FIB, FIB); |
UnLock(lock); |
#endif |
|
Hunt(dbFile, argv[optind]); |
|
return 0; |