Pol  Revision:3cfda13
forspcnt.cpp
Go to the documentation of this file.
1 
7 #include "Header_Windows.h"
8 #include "clib.h"
9 #include <stdio.h>
10 
11 namespace Pol
12 {
13 namespace Clib
14 {
15 int forspec( const char* spec, void ( *func )( const char* pathname ) )
16 {
17  int nProc = 0;
18  HANDLE hFind;
19  WIN32_FIND_DATA find;
20  char fullpath[MAX_PATH];
21  size_t lenleft;
22  char* fname;
23 
24  GetFullPathName( spec, sizeof fullpath, fullpath, &fname );
25  lenleft = sizeof fullpath - ( fname - fullpath );
26 
27  hFind = FindFirstFile( spec, &find );
28  if ( hFind != INVALID_HANDLE_VALUE )
29  {
30  do
31  {
32  ++nProc;
33  strzcpy( fname, find.cFileName, lenleft );
34  if ( func != NULL )
35  ( *func )( fullpath );
36  } while ( FindNextFile( hFind, &find ) );
37  FindClose( hFind );
38  }
39  return nProc;
40 }
41 }
42 }
int forspec(const char *spec, void(*func)(const char *pathname))
Definition: forspcnt.cpp:15
#define strzcpy
Definition: clib.h:154
Definition: berror.cpp:12