ReactOS  0.4.14-dev-49-gfb4591c
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 
12 BOOL 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 );
22  WIN32_FIND_DATA wfd;
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 }
#define TRUE
Definition: types.h:120
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define assert(x)
Definition: debug.h:53
BOOL EnumDirs(const TCHAR *szDirectory_, const TCHAR *szFileSpec, MYENUMDIRSPROC pProc, long lParam)
Definition: EnumDirsImpl.h:12
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _MAX_PATH
Definition: utility.h:77
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define FindFirstFile
Definition: winbase.h:3599
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define FindNextFile
Definition: winbase.h:3605
#define MAX_PATH
Definition: compat.h:26
#define _sntprintf
Definition: xmlstorage.h:201
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
BOOL(* MYENUMDIRSPROC)(PWIN32_FIND_DATA, long)
Definition: EnumDirs.h:12
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502