Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QCoreApplication>
- #include <QDir>
- #include <QDebug>
- void printDir(const QDir& dir, const QString& indent)
- {
- QStringList nameFilter;
- nameFilter << "*.mp3" << "*.ogg" << "*.wav";
- QFileInfoList list = dir.entryInfoList( nameFilter, QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks, QDir::DirsFirst );
- foreach (QFileInfo f, list){
- if(f.isFile())
- {
- qDebug() << indent << "FILE: " << f.fileName() << " --- " << f.filePath();
- }
- else
- {
- qDebug() << indent << "DIR: " << f.fileName() << " --- " << f.filePath();
- printDir(QDir(f.absoluteFilePath()), indent + QString(" "));
- }
- }
- }
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- QDir test("C:\\Users\\kkowalsk\\Downloads");
- printDir(test, QString(""));
- return a.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment