Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <io.h>
    long _findfirst( char *filespec,
                     struct _finddata_t *fileinfo );
    long _wfindfirst( wchar_t *filespec,
                      struct _wfinddata_t *fileinfo );

Description:
    The  _findfirst function returns information on the first file whose
    name matches the filespec argument.  The filespec argument may contain
    wildcard characters ('?' and '*').  The information is returned in a
     _finddata_t structure pointed to by fileinfo.


         struct _finddata_t {
           unsigned  attrib;
           time_t    time_create;  /* -1 for FAT file systems */
           time_t    time_access;  /* -1 for FAT file systems */
           time_t    time_write;
           _fsize_t  size;
           char      name[260];
         };

    The wide-character _wfindfirst function is similar to the _findfirst
    function but operates on wide-character strings.


         struct _wfinddata_t {
           unsigned  attrib;
           time_t    time_create;  /* -1 for FAT file systems */
           time_t    time_access;  /* -1 for FAT file systems */
           time_t    time_write;
           _fsize_t  size;
           wchar_t   name[260];
         };


Returns:
    If successful, _findfirst returns a unique search handle identifying the
    file or group of files matching the filespec specification, which can be
    used in a subsequent call to  _findnext or to  _findclose.  Otherwise,
    _findfirst and returns -1 and sets  errno to one of the following
    values:

    Constant     Meaning

ENOENT
    No matching files

EINVAL
    Invalid filename specification


Example:
    #include <stdio.h>
    #include <io.h>

    void main()
      {
        struct _finddata_t  fileinfo;
        long                handle;
        int                 rc;

        /* Display name and size of "*.c" files */
        handle = _findfirst( "*.c", &fileinfo );
        rc = handle;
        while( rc != -1 ) {
          printf( "%14s %10ld\n", fileinfo.name,
                                  fileinfo.size );
          rc = _findnext( handle, &fileinfo );
        }
        _findclose( handle );
      }

Classification:
    _findfirst is DOS, _wfindfirst is not DOS

Systems:
     _findfirst - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

    _wfindfirst - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    _dos_find Functions, _findclose, _findnext, closedir, opendir, readdir

See Also: _findclose

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