I'm writing a utility function to list files & folders recursively/non-recursively in a given directory and returning the output as QStringList.
{
if(!dir.exists())
if(recursive)
{
QDirIterator iterator(path, QDirIterator::Subdirectories);
while(iterator.hasNext())
{
list << iterator.next();
}
}
else
{
QDirIterator iterator(path, QDirIterator::NoIteratorFlags);
while(iterator.hasNext())
{
list << iterator.next();
}
}
return list;
}
QStringList Utility::dirListing(const QString & path, bool recursive)
{
QDir dir(path);
if(!dir.exists())
return QStringList();
QStringList list;
if(recursive)
{
QDirIterator iterator(path, QDirIterator::Subdirectories);
while(iterator.hasNext())
{
list << iterator.next();
}
}
else
{
QDirIterator iterator(path, QDirIterator::NoIteratorFlags);
while(iterator.hasNext())
{
list << iterator.next();
}
}
return list;
}
To copy to clipboard, switch view to plain text mode
But will this be fine for large data set ?
How can I do this batch wise ?
Kindly give me some hints to handle this case. Thank you.
Bookmarks