[Qt-interest] qdiriterator
caius ligarius
caius9090 at gmail.com
Thu Apr 14 22:16:12 CEST 2011
Thanks. Does this automatically sort by time or will I need to parse through
the iterator and pick the last file?
caius
On Thu, Apr 14, 2011 at 12:30 PM, Rohan Prabhu <rohan at rohanprabhu.com>wrote:
> Use:
>
> QDirIterator dirIter("/home/user/path/to/directory",
> QStringList(QString("stats*.txt")), QDir::Files);
>
> or, if you intend to read those files as well, and hence would like to
> iterator over files which are readable:
>
> QDirIterator dirIter("/home/user/path/to/directory",
> QStringList(QString("stats*.txt")), QDir::Files|QDir::Readable);
>
> then simply iterator over the QDirIterator:
>
> while(dirIter.hasNext()) {
> QString filePath = dirIter.next();
> // Do something with filePath
> }
>
> Hope it helps.
>
> Regards,
> rohan
>
> On Fri, Apr 15, 2011 at 12:40 AM, caius ligarius <caius9090 at gmail.com>wrote:
>
>> I have the path to some parent folder say some QString targetDir. I would
>> like to pick up the latest file (time of creation) which begins with
>> "stats*.txt". I think I need to use QDirIterator but I am not sure how I can
>> use it for my specific use.
>>
>> Could somebody please help?
>>
>> Thanks,
>> Caius
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110414/f7ac4564/attachment.html
More information about the Qt-interest-old
mailing list