//--------------------------------------------------------------------------- uint FileIterator::getFilesList (const char* pszDirectory, bool bRecursive, StringAVec& vecOutFiles, flags8 fQueryFilter/*=QUERY_DIRS_AND_FILES*/) { FileIterator fit; FileInfo fi; uint uiCounter = 0; fi.fQueryFlags = QUERY_NAMEONLY | (fQueryFilter & QUERYMASK_FILTERS); if (bRecursive) fi.fQueryFlags |= QUERY_TYPE | QUERY_DIRS; if (fit.openDir(pszDirectory, fi)) { do { if ((fi.eType == TYPE_DIRECTORY && (fQueryFilter & QUERY_DIRS)) || (fi.eType == TYPE_FILE && (fQueryFilter & QUERY_FILES))) { vecOutFiles.push_back(fit.getDirectory() / fi.strName); ++uiCounter; } if (bRecursive && fi.eType == TYPE_DIRECTORY) { uiCounter += FileIterator::getFilesList( fit.getDirectory() / fi.strName, bRecursive, vecOutFiles, fQueryFilter); } } while (fit.getNext(fi)); } return uiCounter; }
//--------------------------------------------------------------------------- uint FileIterator::getFilesInfo (const char* pszDirectory, bool bRecursive, std::vector<FileIterator::FileInfo>& vecOutFilesInfo, flags8 fQueryFlags/*=QUERY_DIRS_AND_FILES*/) { FileIterator fit; FileInfo fi; uint uiCounter = 0; fi.fQueryFlags = fQueryFlags; if (bRecursive) fi.fQueryFlags |= QUERY_TYPE | QUERY_DIRS; if (fit.openDir(pszDirectory, fi)) { do { fi.strName = fit.getDirectory() / fi.strName; if ((fi.eType == TYPE_DIRECTORY && (fQueryFlags & QUERY_DIRS)) || (fi.eType == TYPE_FILE && (fQueryFlags & QUERY_FILES))) { vecOutFilesInfo.push_back(fi); ++uiCounter; } if (bRecursive && fi.eType == TYPE_DIRECTORY) { uiCounter += FileIterator::getFilesInfo( fi.strName, bRecursive, vecOutFilesInfo, fQueryFlags); } } while (fit.getNext(fi)); } return uiCounter; }