Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>findfirst() search disk directory</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
findfirst()              Search Disk Directory

 #include   <dir.h>
 #include   <dos.h>

 int          findfirst(pathname,ffblk,attrib);
 char         *pathname;                 Name of file to be found
 struct ffblk *ffblk;                    File directory information
 int          attrib;                    Attribute word

    findfirst() uses MS-DOS system call 0x4E to search a disk directory
    for the file associated with 'pathname'.  'pathname' is a string
    consisting of an optional drive specifier, a path name and a file
    name. (The file name portion may contain wildcard characters such as
    ? and *.)  If the file is found, the 'ffblk' structure is filled with
    file-directory information.  The format of the structure 'ffblk' is
    as follows:

          struct ffblk  {
               char ff_reserved[21];         /* Reserved by DOS */
               char ff_attrib;               /* Attribute found */
               int ff_ftime;                 /* File time */
               int ff_fdate;                 /* File date */
               long ff_fsize;                /* File size */
               char ff_name[13];             /* Found file name */
          };

    'attrib' is used in selecting eligible files for the search. 'attrib'
    can be one of the following constants (defined in <dos.h>):

                FA_RDONLY     Read only attribute
                FA_HIDDEN     Hidden file
                FA_SYSTEM     System file
                FA_LABEL      Volume label
                FA_DIREC      Directory
                FA_ARCH       Archive

    Returns:    0 is returned if a file matching 'pathname' is found.  If
                no more files can be found or on error, -1 is returned
                and 'errno' (defined in <stdlib.h>) is set to one of the
                following:

                ENOENT        Path or file name not found
                ENMFILE       No more files

See Also: findnext()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson