Borland C++ reference

_dos_findfirst

raw OCR

Searches a disk directory.

Defined in header <dos.h>

Syntax

#include <dos.h>
unsigned  _dos_findfirst(const char *pathname, int attrib,
                            struct findj Jfblk);

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

_dos_f indtirst begins a search of a disk directory by using the DOS function 0x4E.

pathname is a string with an optional drive specifier, path, and file name of the file to be found. The file name portion can contain wildcard match characters (such as ? or *). If a matching file is found, the find_t structure pointed to by ffblk is filled with the file-directory information.

The format of the find t structure is as follows:

truct find_t {

char reserved[21];/*reserved by DOSV
char attrib;/*attribute foundV
int wr_time;/*file time */
int wr_date;/*file date */
long size;/*file size */
char name[13];/*found file nameV

attrib is a DOS file-attribute byte used in selecting eligible files for the search, attrib is an OR combination of one or more of the following constants (defined in dos.h):

A NORMALNormal file
A_RDONLYRead-only attribute
_A_HIDDENHidden file
A_SYSTEMSystem file
A_VOLIDVolume label
A_SUBDIRDirectory
A ARCHArchive

For more detailed information about these attributes, refer to your DOS reference manuals.

Note that zvrjtime and wr_date contain bit fields for referring to the file's date and time. The structure of these fields was established by DOS. Both are 16-bit structures divided into three fields.

wr_time:

bits 0-4The result of seconds divided by 2 (e.g., 10 here means 20 seconds)
bits 5-10Minutes
bits 11-15Hours

wr_date:

bits 0-4Day
bits 5-8Month
bits 9-15Years since 1980 (e.g., 9 here means 1989)

Return value

_dos_findflrst returns 0 on successfully finding a file matching the search pathname. When no more files can be found, or if there is some error in the file name, the DOS error code is returned, and the global variable errno is set to ENOENT Path or file name not found

See also

Example

include  <stdio.h>
#include <dos.h>

int main(void)
{
   struct find_t ffblk;
   int done;
   printf("Directory listing of *.*\n");
   done = _dos_findfirst("*.*",_A_NORMAL,&ffblk);
   while (Idone) {
      printfC   %s\n", ffblk.name) ;
      done = _dos_findnext (&ffblk);
   }
   return 0;
Program   output

   Directory listing of *.*
     FINDFRST.C
     FINDFRST.OBJ
     FINDFRST.MAP
     FINDFRST.EXE

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `dos findfirst` read as `_dos_findfirst`