ReactOS 0.4.16-dev-340-g0540c21
EnumDirsImpl.h
Go to the documentation of this file.
1//
2// EnumDirs.cpp
3//
4
5#include "EnumDirs.h"
6#include <stdio.h>
7
8#if defined(UNDER_CE) && !defined(assert)
9#define assert(x)
10#endif
11
12BOOL EnumDirs ( const TCHAR* szDirectory_, const TCHAR* szFileSpec, MYENUMDIRSPROC pProc, long lParam )
13{
14 assert ( szDirectory_ && szFileSpec && pProc );
15 TCHAR szDirectory[MAX_PATH+1];
16 TCHAR szSearchPath[MAX_PATH+1];
17 TCHAR szTemp[MAX_PATH+1];
18 _tcscpy ( szDirectory, szDirectory_ );
19 if ( szDirectory[_tcslen(szDirectory)-1] != '\\' )
20 _tcscat ( szDirectory, _T("\\") );
21 _sntprintf ( szSearchPath, _MAX_PATH, _T("%s%s"), szDirectory, szFileSpec );
23 HANDLE hfind = FindFirstFile ( szSearchPath, &wfd );
24 if ( hfind == INVALID_HANDLE_VALUE )
25 return TRUE;
26 do
27 {
28 if ( !_tcscmp ( wfd.cFileName, _T(".") ) || !_tcscmp ( wfd.cFileName, _T("..") ) )
29 continue;
30 _sntprintf ( szTemp, _MAX_PATH, _T("%s%s"), szDirectory, wfd.cFileName );
31 if ( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
32 {
33 if ( !pProc ( &wfd, lParam ) )
34 {
35 FindClose ( hfind );
36 return FALSE;
37 }
38 }
39 } while ( FindNextFile ( hfind, &wfd ) );
40 FindClose ( hfind );
41 return TRUE;
42}
BOOL EnumDirs(const TCHAR *szDirectory_, const TCHAR *szFileSpec, MYENUMDIRSPROC pProc, long lParam)
Definition: EnumDirsImpl.h:12
BOOL(* MYENUMDIRSPROC)(PWIN32_FIND_DATA, long)
Definition: EnumDirs.h:12
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
#define assert(x)
Definition: debug.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _tcscmp
Definition: tchar.h:1424
#define _tcscat
Definition: tchar.h:622
#define _tcscpy
Definition: tchar.h:623
#define _MAX_PATH
Definition: utility.h:77
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define _T(x)
Definition: vfdio.h:22
#define FindNextFile
Definition: winbase.h:3813
#define FindFirstFile
Definition: winbase.h:3807
char TCHAR
Definition: xmlstorage.h:189
#define _sntprintf
Definition: xmlstorage.h:201
#define _tcslen
Definition: xmlstorage.h:198