Qt4 configured with -largefile
Hi,
I am building qt-4.3.2 32-bit with "-largefile" flag, but it does not seems to work.
I have a large file system. I try the following codes:
QDir myDir( path )
QStringList fileList = myDir.entryList();
It returns fileList.size() = 0, even thought there are several files in the path.
If I do QFile::exists( path/file ), it will return true.
As a result, I can't list the files in the directory...so I can't find any file I need...
If I build 64-bit application, all files can be seen....
Can someone please tell me what is the problem?
Thanks
Re: Qt4 configured with -largefile
Case closed.
It is a Qt bug to use opendir (src/corelib/io/qfsfileengine_iterator_unix.cpp) trying to access directory in large filesystem.
scandir64 fixes the problem
Code:
static QStringList getFileList
( const char* dirname,
const QRegExp
& filter
) {
struct dirent64 **namelist=NULL;
int sz = scandir64( dirname, &namelist, 0 , alphasort );
for ( int idx=0; idx < sz; idx++ ) {
if ( QString( namelist
[idx
]->d_name
).
contains( filter
) ) { fullpath += "/";
fullpath += namelist[idx]->d_name;
fileList << fullpath;
}
}
if ( sz > 0 ) {
while( sz-- ) {
free( namelist[sz] );
}
free( namelist );
}
return fileList;
} // getFileList