_findfirsti64, _wfindfirsti64

From RAD Studio
Jump to: navigation, search

Go Up to io.h Index


Header File

io.h, wchar.h

Category

Directory Control Routines

Prototype

long _findfirsti64(char *filter, struct _finddatai64_t *fileinfo);

long _wfindfirsti64(wchar_t *filter, struct _wfinddatai64_t *fileinfo);

Description

Begins a search of a disk directory to find information about the first instance of a filename that matches a specified filter. The filter parameter is a string that specifies which files to return. Wildcards may be used in the filter. The fileinfo parameter is the file information buffer. If a matching file is found, the fileinfo structure is filled with the file-directory information.

These i64 versions are for 64 bit filesize use and are provided for Microsoft compatibility.

Return Value

On success, returns a unique search handle identifying the file or group of files matching the filter specification.

Otherwise, returns -1 and sets errno to one of the following values:

ENOENTFile specification that could not be matched

EINVALInvalid filename specification

Example

#include <io.h>
void print_dir(wchar_t* dir_name)
{
  /* Open a find stream (_wfinddatai64_t and a find handle) */
  _wfinddatai64_t find_data;
  long handle = _wfindfirsti64(dir_name, &find_data);

  /* Check for errors */
  if (!handle)
    return;

  /* Scan all files that mach */ 
  do 
  {
    printf("%ls\n", find_data.name);
  } while (!_wfindnexti64(handle, &find_data));

  /* Close the find handle */
  _findclose(handle);
}

Portability

POSIX Win32 ANSI C ANSI C++

_findfirsti64

+

_wfindfirsti64

NT only