findnext, _wfindnext

From RAD Studio
Jump to: navigation, search

Go Up to dir.h Index


Header File

dir.h

Category

Directory Control Routines

Prototype

int findnext(struct ffblk *ffblk );

int _wfindnext(struct _wffblk *ffblk );

Description

Continues findfirst search.

findnext is used to fetch subsequent files that match the pathname given in findfirst. ffblk is the same block filled in by the findfirst call. This block contains necessary information for continuing the search. One file name for each call to findnext will be returned until no more files are found in the directory matching the pathname.

Return Value

findnext returns 0 on successfully finding a file matching the search pathname. When no more files can be found or if there is an error in the file name

-1 is returned

errno is set to

ENOENT

Path or file name not found



_doserrno is set to one of the following values:

ENMFILE

No more files

ENOENT

Path or file name not found


Example

#include <stdio.h>
#include <dir.h>
void print_dir(wchar_t* dir_name)
{
  /* Open a find stream (_wfinddata_t and a find handle) */ 
  _wffblk find_data;
  int done;

  done = _wfindfirst(dir_name, &find_data, 0);

  /* Scan all files that mach */
  while (!done)
  {
    printf("%ls\n", find_data.ff_name);
    done = _wfindnext(&find_data);
  }

  /* Close the find handle */
  _wfindclose(&find_data);
}

Portability

POSIX Win32 ANSI C ANSI C++

findnext

+

_wfindnext

NT only

See Also