diff options
author | João Abecasis <joao@trolltech.com> | 2010-01-21 18:48:33 (GMT) |
---|---|---|
committer | João Abecasis <joao@trolltech.com> | 2010-01-29 13:33:49 (GMT) |
commit | 1492a2edf269b368abd2af9f8ffb474489609b5d (patch) | |
tree | a009a5ff373b739b8f5d06814e49b9675d1b6788 /src/corelib/io | |
parent | 6d8ea540bd123270f0010eb5fa5e68a510ca89e7 (diff) | |
download | Qt-1492a2edf269b368abd2af9f8ffb474489609b5d.zip Qt-1492a2edf269b368abd2af9f8ffb474489609b5d.tar.gz Qt-1492a2edf269b368abd2af9f8ffb474489609b5d.tar.bz2 |
Use X/Open LFS extensions for 64-bit support on directory iteration
This boils down to using readdir64(_r) and struct dirent64 where
available. I assumed these are available in the same platforms other
such extensions are already being used.
AIX uses the additional type DIR64 and opendir64/closedir64 to
manipulate it.
Task-number: QTBUG-2781
Reviewed-by: Thiago Macieira
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_dnotify.cpp | 13 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_iterator_unix.cpp | 20 |
2 files changed, 17 insertions, 16 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_dnotify.cpp b/src/corelib/io/qfilesystemwatcher_dnotify.cpp index 1a218c7..82470c8 100644 --- a/src/corelib/io/qfilesystemwatcher_dnotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_dnotify.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "qplatformdefs.h" #include "qfilesystemwatcher.h" #include "qfilesystemwatcher_dnotify_p.h" @@ -255,16 +256,16 @@ QStringList QDnotifyFileSystemWatcherEngine::addPaths(const QStringList &paths, if(fd == 0) { - DIR *d = ::opendir(path.toUtf8().constData()); + QT_DIR *d = QT_OPENDIR(path.toUtf8().constData()); if(!d) continue; // Could not open directory - DIR *parent = 0; + QT_DIR *parent = 0; QDir parentDir(path); if(!parentDir.isRoot()) { parentDir.cdUp(); - parent = ::opendir(parentDir.path().toUtf8().constData()); + parent = QT_OPENDIR(parentDir.path().toUtf8().constData()); if(!parent) { - ::closedir(d); + QT_CLOSEDIR(d); continue; } } @@ -272,8 +273,8 @@ QStringList QDnotifyFileSystemWatcherEngine::addPaths(const QStringList &paths, fd = qt_safe_dup(::dirfd(d)); int parentFd = parent ? qt_safe_dup(::dirfd(parent)) : 0; - ::closedir(d); - if(parent) ::closedir(parent); + QT_CLOSEDIR(d); + if(parent) QT_CLOSEDIR(parent); Q_ASSERT(fd); if(::fcntl(fd, F_SETSIG, SIGIO) || diff --git a/src/corelib/io/qfsfileengine_iterator_unix.cpp b/src/corelib/io/qfsfileengine_iterator_unix.cpp index b68b1a1..bfdb03e 100644 --- a/src/corelib/io/qfsfileengine_iterator_unix.cpp +++ b/src/corelib/io/qfsfileengine_iterator_unix.cpp @@ -58,13 +58,13 @@ public: #endif {} - DIR *dir; - dirent *dirEntry; + QT_DIR *dir; + QT_DIRENT *dirEntry; bool done; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) // for readdir_r - dirent *mt_file; + QT_DIRENT *mt_file; #endif }; @@ -76,14 +76,14 @@ void QFSFileEngineIterator::advance() return; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) - if (::readdir_r(platform->dir, platform->mt_file, &platform->dirEntry) != 0) + if (QT_READDIR_R(platform->dir, platform->mt_file, &platform->dirEntry) != 0) platform->done = true; #else // ### add local lock to prevent breaking reentrancy - platform->dirEntry = ::readdir(platform->dir); + platform->dirEntry = QT_READDIR(platform->dir); #endif // _POSIX_THREAD_SAFE_FUNCTIONS if (!platform->dirEntry) { - ::closedir(platform->dir); + QT_CLOSEDIR(platform->dir); platform->dir = 0; platform->done = true; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) @@ -101,7 +101,7 @@ void QFSFileEngineIterator::newPlatformSpecifics() void QFSFileEngineIterator::deletePlatformSpecifics() { if (platform->dir) { - ::closedir(platform->dir); + QT_CLOSEDIR(platform->dir); #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) delete [] platform->mt_file; platform->mt_file = 0; @@ -115,18 +115,18 @@ bool QFSFileEngineIterator::hasNext() const { if (!platform->done && !platform->dir) { QFSFileEngineIterator *that = const_cast<QFSFileEngineIterator *>(this); - if ((that->platform->dir = ::opendir(QFile::encodeName(path()).data())) == 0) { + if ((that->platform->dir = QT_OPENDIR(QFile::encodeName(path()).data())) == 0) { that->platform->done = true; } else { // ### Race condition; we should use fpathconf and dirfd(). long maxPathName = ::pathconf(QFile::encodeName(path()).data(), _PC_NAME_MAX); if ((int) maxPathName == -1) maxPathName = FILENAME_MAX; - maxPathName += sizeof(dirent) + 1; + maxPathName += sizeof(QT_DIRENT) + 1; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) if (that->platform->mt_file) delete [] that->platform->mt_file; - that->platform->mt_file = (dirent *)new char[maxPathName]; + that->platform->mt_file = (QT_DIRENT *)new char[maxPathName]; #endif that->advance(); |