f_findfirst


Use this function to find the first file or subdirectory in a specified directory.

First call f_findfirst() and then, if the file is found, get the next file with f_findnext(). Files with the system attribute set are ignored.

Note: If this function is called with "*.*" and it is not the root directory:

  • The first entry found will be ".", the current directory.
  • The second entry is “..”,  the parent directory.

Format

int f_findfirst (
    const char *   filename,
    F_FIND *       find )

Arguments

Argument Description Type
filename The name of the file to find. char *
find Where to store the find information. F_FIND *

Return values

Return value Description
F_NOERR Successful execution.
Else See Error Codes.

Example

void mydir()
{
    F_FIND find;
    if (!f_findfirst( "A:/subdir/file*.*", &find ))
    {
        do
        {
            printf( "filename:%s", find.filename );
            if (find.attr&F_ATTR_DIR)
            {
                printf( " directory\n" );
            }
            else
            {
                printf( " size %d\n", find.filesize );
            }
        }
        while (!f_findnext( &find ));
    }
}