Hi,
I'm trying to iterate over directories trees to search for any files in them. This can't be a function so recursing is not possible.
Best example of what i'm trying to do below. It works perfectly, except it is a recusive function so it's no use to me.
It also needs to be kept pure C and use the win32 api.
I'm trying to iterate over directories trees to search for any files in them. This can't be a function so recursing is not possible.
Best example of what i'm trying to do below. It works perfectly, except it is a recusive function so it's no use to me.
Code
void WINAPI SearchFile(PSTR Directory)
{
HANDLE hFind;
WIN32_FIND_DATA FindData;
char SearchName[1024],FullPath[1024];
memset(SearchName,0,sizeof(SearchName));
memset(&FindData,0,sizeof(WIN32_FIND_DATA));
sprintf(SearchName,"%s\\*",Directory);
hFind=FindFirstFile(SearchName,&FindData);
if(hFind!=INVALID_HANDLE_VALUE)
{
while(FindNextFile(hFind,&FindData))
{
if(FindData.cFileName[0]=='.')
{
continue;
}
memset(FullPath,0,sizeof(FullPath));
sprintf(FullPath,"%s\\%s",Directory,FindData.cFileName);
if(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
MessageBoxA(NULL, FullPath, "Directory", MB_OK);
SearchFile(FullPath);
}
else
{
MessageBoxA(NULL, FullPath, "File", MB_OK);
}
}
FindClose(hFind);
}
}It also needs to be kept pure C and use the win32 api.

