edit: (Maybe this should have been posted at the "Newbie" section)
Hi
I'm trying to get all folder names with absolute paths. My question is maybe kinda simple, does my implementation have any pitfalls?
dir.
entryList(QDir::Dirs |
QDir::NoDotAndDotDot).
replaceInStrings(QRegExp("^"),dir.
absolutePath())
QDir dir("R:/");
dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot).replaceInStrings(QRegExp("^"),dir.absolutePath())
To copy to clipboard, switch view to plain text mode
QDir::entryList() only returns a QStringList containing directory names without full paths.
So my simple one line solution would be using QStringList::replaceInStrings() with
parameters QRegExp("^") and dir.absolutePath(),
which should add the string "R:/" as a prefix to each directory entry, giving me full paths.
As I said, does my solution have any pitfalls like for example if the QRegExp("^") might get applied elsewhere in the string instead of only in the beginning as a prefix?
I have tried naming folders with spaces, symbols and it seems to me that it works.
Maybe I'm just paranoid but I would love to hear about your expert opinions
. Much appreciated.
Also, would be nice if you guys and gals could share your favorite solutions.
(It's a pity IMHO that QDir::absoluteEntryList() doesn't exist)
Thanks for reading
Bookmarks