[Qt-interest] QDir Loop Problem

Denis Mingulov denis at mingulov.com
Thu Apr 8 08:12:35 CEST 2010


Hi,

>        else if(fileInfo.isDir())
>        {
>            qDebug() << "Looping in : " << fileInfo.absolutePath();
>            findStringInDir(fileInfo.absolutePath());
>        }

It is correct, absolutePath() is the same for any usual file in one folder.
You should use fileInfo.absoluteFilePath()

http://doc.trolltech.com/4.6/qfileinfo.html#absolutePath

-- 
Best Regards,
Denis Mingulov





On Thu, Apr 8, 2010 at 8:26 AM, Aaron Lewis <aaron.lewis1989 at gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>        I'm trying to go through a directory , loop all of the files under it ,
> but it never change to another directory
>
> Caller will pass a absolute directory path to finder::findStringInDir.
>
> =====================================================================================
>
> - -snip-
>    QDir dir(dirName);  // pass in an absolute path , some directory
> check code is snipped.
>    QFileInfoList list = dir.entryInfoList();
>    for(int i=0;i<list.size();i++)
>    {
>        QFileInfo fileInfo = list.at(i);
>        if(fileInfo.fileName() == "." || fileInfo.fileName() == "..")
>            continue;
>
>        if(fileInfo.isFile())
>        {
>            findStringInFile(fileInfo.absoluteFilePath());
>        }
>        else if(fileInfo.isDir())
>        {
>            qDebug() << "Looping in : " << fileInfo.absolutePath();
>            findStringInDir(fileInfo.absolutePath());
>        }
>    }// for loop
> - -snip-
>
>
>
>
> When i launched it , my screen flooded with same debug string like this:
> ================================================================================================
>
> Looping in :  "/path/to/dir"
>
> ================================================================================================
>
> Does anyone has any ideas ?
>
> Thanks in advance !
>
> - --
> Best Regards,
> Aaron Lewis - PGP: 0x4A6D32A0
> FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
> irc: A4r0n on freenode
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.14 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAku9aRUACgkQvf41sEptMqAkAQCgwWV0lGpSVtgflnJc9EUp4+io
> ZBYAnRvQp0su1xparGCWJrjp+DJylr/5
> =bEf7
> -----END PGP SIGNATURE-----
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




More information about the Qt-interest-old mailing list