// Check to see that this is a valid directory.
String sDummy = String(_T("0"));
int iDirchk = CheckForFile(rsDIR, sDummy, true);
if (!iDirchk)
{
fprintf(f,"0,%s\n",rsDIR.c_str());
// We are now in a Directory.
String sDirectory = rsDIR;
sDirectory += String(_T("\\"));
String sSearch = sDirectory;
sSearch += String(_T("*.*"));
// We want to scan through this directory and extract all of the files.
if ( (h=FindFirstFile(sSearch.c_str(),&finfo))!=INVALID_HANDLE_VALUE)
{
do
{
if(!(finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
// Yipeee we have found a file.
// Construct the full name for this file.
String sFullPath = sDirectory;
String sVersion;
sFullPath += String(finfo.cFileName);
if (GetVersionStringForFile(sFullPath,sVersion))
{
// File got version info.
fprintf(f,"1,%s,%s\n",sFullPath.c_str(),sVersion.c_str());
}
else
{
// File not got version info.
fprintf(f,"1,%s,0\n",sFullPath.c_str());
}
}
}while (FindNextFile(h,&finfo));
FindClose (h);
}
// Search for Directories.
if ( (h=FindFirstFile(sSearch.c_str(),&finfo))!=INVALID_HANDLE_VALUE)
{
do
{
if(finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
// Yipeee we have found a directory.
// Make sure it is not '.' or '..'
if (_tcsncmp(finfo.cFileName ,_T("."),1) &&
_tcsncmp(finfo.cFileName,_T(".."),2))
{
// Construct the full name for this directory.
String sFullPath = sDirectory;
sFullPath += String(finfo.cFileName);
// Lets call ourselves with this new directory.
iRet = BuildCSVFile(sFullPath, f);
}
}
}while (FindNextFile(h,&finfo));
FindClose (h);
}