Ich enumiere alle Ordner eines Pfads bzw. eines Datenträgers und suche nach leeren Ordnern.
Soweit so gut, hab ichs geschafft, wollte aber fragen ob ich die rekursion besser gestalten kann, weil ich so ein Gefühl habe, dass man es sicher besser machen kann
Danke in vorraus!
Code:
int searchEmptyDirs(vector<string> &storedFiles, const string &startDir)
{
string strFilePath;
string strPattern;
HANDLE hFile;
WIN32_FIND_DATA fileInformation;
strPattern = startDir + "\\*.*";
hFile = FindFirstFileA(strPattern.c_str(), &fileInformation);
if(hFile != INVALID_HANDLE_VALUE)
{
do
{
if(fileInformation.cFileName[0] != '.')
{
strFilePath.erase();
strFilePath = startDir + "\\" + fileInformation.cFileName;
if(fileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if(PathIsDirectoryEmpty(strFilePath.c_str()))
{
storedFiles.push_back(strFilePath);
}
int res = searchEmptyDirs(storedFiles, strFilePath);
if(res)
return res;
}
}
}while(FindNextFileA(hFile, &fileInformation) == TRUE);
FindClose(hFile);
DWORD dwError = GetLastError();
if(dwError != ERROR_NO_MORE_FILES)
return dwError;
}
return 0;
}
Und wie gehe ich Ordner die mit einem '.' beginnen durch? Also zB: .Bilder






