I have a little problem using Qt functions to recursively navigate through a directory. What am I trying to do:
Open the specified directory. Go through the directory and each time it encounters another directory, open this directory, go through files, etc.
Now how do I do this:
QString dir = QFileDialog::getExistingDirectory(this, "Select directory"); if(!dir.isNull()) { ReadDir(dir); } void Mainwindow::ReadDir(QString path) { QDir dir(path);
Now, the actual problem I ran into: naturally, entryInfoList would also return '.' and "..". With this setup, this is a serious problem.
Going to "." , it will go through the entire directory twice or even endlessly (because "." is always the first element), with ".." it will repeat the process for all folders under the parent directory.
I would like to do it beautifully and smoothly, is there any way around this, I donβt know? Or is this the only way to get an explicit file name (without a path) and check it against "." . and '..'?
source share