home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
fish
/
telecom
/
uucp_442
/
src
/
lib
/
isdir.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-08
|
1KB
|
62 lines
/*
* IsDir
*
* Confirms that the specified path is a directory.
*
* Copyright 1990 by J. Gregory Noel, All Rights Reserved.
*/
#include <libraries/dos.h>
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "version.h"
IDENT(".01");
Prototype int IsDir(const char *);
/*
* The fib must be longword aligned and thus cannot be allocated
* on the stack or statically.
*/
int
IsDir(const char *path)
{
BPTR lock;
struct FileInfoBlock *fib;
int r = 0;
if (fib = malloc(sizeof(struct FileInfoBlock))) {
if (lock = Lock(path, ACCESS_READ)) {
if (Examine(lock, fib)) {
if (fib->fib_DirEntryType > 0)
r = 1;
}
UnLock(lock);
}
free(fib);
}
return(r);
}
#ifdef TEST
extern int main(int argc, char **argv);
main(int argc, char **argv)
{
char command[100];
if (argc < 2) while (gets(command)) {
printf("IsDir(%s) returned %d\n", command, IsDir(command));
} else while (*++argv != NULL) {
printf("IsDir(%s) returned %d\n", *argv, IsDir(*argv));
}
return 0;
}
#endif