kamilosxd678

[QT[ Directory Crawler

Jul 10th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <QCoreApplication>
  2. #include <QDir>
  3. #include <QDebug>
  4.  
  5. void printDir(const QDir& dir, const QString& indent)
  6. {
  7.     QStringList nameFilter;
  8.     nameFilter << "*.mp3" << "*.ogg" << "*.wav";
  9.  
  10.     QFileInfoList list = dir.entryInfoList( nameFilter, QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks, QDir::DirsFirst );
  11.  
  12.     foreach (QFileInfo f, list){
  13.         if(f.isFile())
  14.         {
  15.             qDebug() << indent << "FILE: " << f.fileName() << " --- " << f.filePath();
  16.         }
  17.         else
  18.         {
  19.             qDebug() << indent << "DIR: " << f.fileName() << " --- " << f.filePath();
  20.             printDir(QDir(f.absoluteFilePath()), indent + QString("   "));
  21.         }
  22.     }
  23. }
  24.  
  25. int main(int argc, char *argv[])
  26. {
  27.     QCoreApplication a(argc, argv);
  28.  
  29.     QDir test("C:\\Users\\kkowalsk\\Downloads");
  30.     printDir(test, QString(""));
  31.  
  32.     return a.exec();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment