home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
200-299
/
ff218.lzh
/
EdLib
/
filetype.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-04
|
844b
|
46 lines
/*
* edlib v1.1 Copyright 1989 Edwin Hoogerbeets
* This code is freely redistributable as long as no charge other than
* reasonable copying fees are levied for it.
*/
#include "edlib.h"
#include <libraries/dos.h>
#include <exec/memory.h>
#include <errno.h>
#define FIBSIZE sizeof(struct FileInfoBlock)
extern struct FileInfoBlock *AllocMem();
extern struct FileLock *Lock();
int filetype(path)
char *path;
{
register struct FileInfoBlock *fib;
register struct FileLock *lock;
register int result;
if ( !(fib = AllocMem(FIBSIZE,MEMF_CLEAR)) ) {
errno = ENOMEM;
return(-1);
}
if ( !(lock = Lock(path,ACCESS_READ)) ) {
errno = EACCES;
return(-1);
}
Examine(lock,fib);
result = ( fib->fib_DirEntryType > 0 ) ? TYPE_DIR : TYPE_FILE;
UnLock(lock);
FreeMem(fib,FIBSIZE);
return(result);
}