C++ (Qt)QStringList CFileFindThread::getListFilesFind( const QString &pathr, QStringList filters ){ QStack<QString> dirs; QString path; QStringList listFiles; m_countFiles = 0; if(pathr.isEmpty()) path = QDir::currentPath(); else path = pathr; dirs.push(path); while (!dirs.isEmpty()) { path = dirs.pop(); QDir dir(path); if(!dir.exists()) continue; foreach (QString file, dir.entryList(filters)) ///////////видит папку как файл!!!!!!!!!!!!!!!!!!!!! если имя microsoft.cpp { listFiles << QFileInfo(dir, file).absoluteFilePath(); m_countFiles++; } emit currentCountFiles(m_countFiles); foreach (QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)){ dirs.push(path + QDir::separator() + subDir); } } return listFiles;}
C++ (Qt)QStringList CFileFindThread::getListFilesFindOld( const QString &pathr, QStringList filters ){ QStack<QString> dirs; QString path; QStringList listFiles; m_countFiles = 0; if(pathr.isEmpty()) path = QDir::currentPath(); else path = pathr; dirs.push(path); while (!dirs.isEmpty()) { path = dirs.pop(); QDir dir(path); if(!dir.exists()) continue; foreach (QString file, dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot))// медленней работает алгоритма с двумя циклами { QFileInfo temp(dir,file); if(temp.isDir()) dirs.push(path + QDir::separator() + file); else if(m_FilterNames.contains("*." + temp.suffix(), Qt::CaseInsensitive)) { listFiles << QFileInfo(dir, file).absoluteFilePath(); m_countFiles++; emit currentCountFiles(m_countFiles); } } } return listFiles;}
C++ (Qt)QStringList CFileFindThread::getListFilesFind( const QString &pathr, QStringList filters ){ QStack<QString> dirs; QString path; QStringList listFiles; m_countFiles = 0; if(pathr.isEmpty()) path = QDir::currentPath(); else path = pathr; dirs.push(path); while (!dirs.isEmpty()) { path = dirs.pop(); QDir dir(path); if(!dir.exists()) continue; foreach (QString file, dir.entryList(filters, QDir::Files)) { listFiles << QFileInfo(dir, file).absoluteFilePath(); m_countFiles++; } emit currentCountFiles(m_countFiles); foreach (QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)){ dirs.push(path + QDir::separator() + subDir); } } return listFiles;}
C++ (Qt)QStringList CFileFindThread::getListFilesFindOld( const QString &pathr, QStringList filters ){ QStack<QString> dirs; QString path; QStringList listFiles; m_countFiles = 0; if(pathr.isEmpty()) path = QDir::currentPath(); else path = pathr; dirs.push(path); while (!dirs.isEmpty()) { path = dirs.pop(); QDir dir(path); if(!dir.exists()) continue; foreach (QString file, dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { QFileInfo temp(dir,file); if(temp.isDir()) dirs.push(path + QDir::separator() + file); else if(m_FilterNames.contains("*." + temp.suffix(), Qt::CaseInsensitive)) { listFiles << QFileInfo(dir, file).absoluteFilePath(); m_countFiles++; emit currentCountFiles(m_countFiles); } } } return listFiles;}
C++ (Qt)foreach (QFileInfo file, dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { if(file.isDir()) { ++currentNumberFile; dirs.push(file.absoluteFilePath()); } else { *listFiles << file.absoluteFilePath(); }}