#include <wchar.h>
|
long
wfindfirst (const wchar_t* filespec, struct _wfinddata_t* fileinfo); |
int
wfindnext (intptr_t handle, struct _wfinddata_t * fileinfo); |
int
findclose (intptr_t handle);
|
If successful, wfindfirst return a unique search handle identifying the file or group of files matching the filespec specification, which can be used in a subsequent call to wfindnext or to findclose. Otherwise, wfindfirst returns -1 and sets errno accordingly.
If successful, wfindnext returns 0. Otherwise, returns -1 and sets errno to a value indicating the nature of the failure.
If successful, findclose returns 0. Otherwise, it returns -1 and sets errno to ENOENT
[EINVAL] | |
Invalid parameter: filespec or fileinfo was NULL. Or, the operating system returned an unexpected error.
|
|
[ENOENT] | |
File specification that could not be matched. | |
unsigned attrib |
File attribute
|
time_t time_create | |
Time of file creation (-1L for Symbian)
|
|
time_t time_access | |
Time of the last file access (-1L for Symbian)
|
|
time_t time_write |
Time of the last write to file
|
size_t size |
Length of the file in bytes
|
wchar_t name[260] | Null-terminated name of matched file/directory, without the path |
This attribute is returned in the attrib field of the _wfinddata_t structure and can have the following values (defined in wchar.h).
_A_ARCH | Archive. |
_A_HIDDEN | |
Hidden file. | |
_A_NORMAL | |
Normal. | |
_A_RDONLY | |
Read-only. | |
_A_SYSTEM | |
System file. | |
The wfindnext finds the next name, if any, that matches the filespec argument in a previous call to wfindfirst and then alters the fileinfo structure contents accordingly.
The findclose closes the specified search handle and releases the associated resources.
#include <wchar.h> int main( void ) { struct _wfinddata_t c_file; intptr_t hFile; // Find .txt file in current directory if( (hFile = wfindfirst( L"*.txt", &c_file )) == -1L ) printf( "No *.txt files in current directory" ); else { int i = 1; do { wprintf( L" File %d = %s ",i,c_file.name); i++; } while( wfindnext( hFile, &c_file ) == 0 ); findclose( hFile ); } return 0 ; }
Output
File 1 = test1.txt File 2 = test2.txt
© 2005-2007 Nokia |