| www.delorie.com/djgpp/doc/libc-2.01/libc_273.html | search |
#include <dir.h> int findfirst(const char *pathname, struct ffblk *ffblk, int attrib);
This function and the related findnext (see section findnext) are used
to scan directories for the list of files therein. The pathname
is a wildcard that specifies the directory and files to search for (such
as subdir/*.c), ffblk is a structure to hold the results and
state of the search, and attrib is a combination of the following:
FA_RDONLY
FA_HIDDEN
FA_SYSTEM
FA_LABEL
FA_DIREC
FA_ARCH
Any file that doesn't have any flag bits that aren't specified is
selected for the search. Thus, if you specified FA_DIREC and
FA_LABEL, you would get all subdirectories, the volume label, and
any file that is neither read-only or modified.
The results of the search are stored in ffblk:
struct ffblk {
char ff_reserved[21]; /* used to hold the state of the search */
unsigned char ff_attrib; /* actual attributes of the file found */
unsigned short ff_ftime; /* hours:5, minutes:6, (seconds/2):5 */
unsigned short ff_fdate; /* (year-1980):7, month:4, day:5 */
unsigned long ff_fsize; /* size of file */
char ff_name[16]; /* name of file as ASCIIZ string */
}
Zero if a match is found, nonzero if none found.
struct ffblk f;
int done = findfirst("*.exe", &f, FA_ARCH|FA_RDONLY);
while (!done)
{
printf("%10u %2u:%02u:%02u %2u/%02u/%4u %s\n",
f.ff_fsize,
(f.ff_ftime >> 11) & 0x1f,
(f.ff_ftime >> 5) & 0x3f,
(f.ff_ftime & 0x1f) * 2,
(f.ff_fdate >> 5) & 0x0f,
(f.ff_fdate & 0x1f),
((f.ff_fdate >> 9) & 0x7f) + 1980,
f.ff_name);
done = findnext(&f);
}
Go to the first, previous, next, last section, table of contents.
| prev next webmaster | delorie software privacy |
| Copyright © 1997 | Updated Apr 1997 |