home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 1
/
GoldFishApril1994_CD1.img
/
d1xx
/
d169
/
src
/
suplib
/
scandir.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-11-22
|
1KB
|
77 lines
/*
* SCANDIR.C
*
* SD {
* SD *next;
* char buf[];
* };
*
* SD *sd;
*
* sd = ScanDir(dir, match)
* FreeDirScan(sd)
*/
#include <local/typedefs.h>
#define SD struct _SD
#define DBLK 32
#define ALIGNL(ptr) (void *)(((long)ptr + 3) & ~3)
SD {
SD *next;
char buf[4];
};
/*BREAKUP ScanDir.c */
SD *
ScanDir(dir, match, abortflag)
char *dir, *match;
char *abortflag;
{
char buf[sizeof(FIB)+3];
register FIB *fib = ALIGNL(buf);
register SD *sd;
SD *sbase;
long lock;
char ok = 0;
geta4();
sd = (SD *)&sbase;
lock = Lock(dir, SHARED_LOCK);
if (lock && Examine(lock, fib) && fib->fib_DirEntryType > 0) {
while (ExNext(lock, fib)) {
if (*abortflag)
break;
if (wildcmp(match, fib->fib_FileName)) {
sd->next = AllocMem(sizeof(SD) - 3 + strlen(fib->fib_FileName), MEMF_PUBLIC);
sd = sd->next;
strcpy(sd->buf, fib->fib_FileName);
}
}
UnLock(lock);
sd->next = NULL;
return(sbase);
}
if (lock)
UnLock(lock);
return(NULL);
}
/*BREAKUP FreeDirScan.c */
void
FreeDirScan(sd)
register SD *sd;
{
register SD *nextsd;
geta4();
while (sd) {
nextsd = sd->next;
FreeMem(sd, sizeof(SD) - 3 + strlen(sd->buf));
sd = nextsd;
}
}