uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const { Q_ASSERT(fileEngine); // should never be called when using the native FS // We split the testing into tests for for LinkType, BundleType, PermsMask // and the rest. // Tests for file permissions on Windows can be slow, expecially on network // paths and NTFS drives. // In order to determine if a file is a symlink or not, we have to lstat(). // If we're not interested in that information, we might as well avoid one // extra syscall. Bundle detecton on Mac can be slow, expecially on network // paths, so we separate out that as well. QAbstractFileEngine::FileFlags req = 0; uint cachedFlags = 0; if (request & (QAbstractFileEngine::FlagsMask | QAbstractFileEngine::TypesMask)) { if (!getCachedFlag(CachedFileFlags)) { req |= QAbstractFileEngine::FlagsMask; req |= QAbstractFileEngine::TypesMask; req &= (~QAbstractFileEngine::LinkType); req &= (~QAbstractFileEngine::BundleType); cachedFlags |= CachedFileFlags; } if (request & QAbstractFileEngine::LinkType) { if (!getCachedFlag(CachedLinkTypeFlag)) { req |= QAbstractFileEngine::LinkType; cachedFlags |= CachedLinkTypeFlag; } } if (request & QAbstractFileEngine::BundleType) { if (!getCachedFlag(CachedBundleTypeFlag)) { req |= QAbstractFileEngine::BundleType; cachedFlags |= CachedBundleTypeFlag; } } } if (request & QAbstractFileEngine::PermsMask) { if (!getCachedFlag(CachedPerms)) { req |= QAbstractFileEngine::PermsMask; cachedFlags |= CachedPerms; } } if (req) { if (cache_enabled) req &= (~QAbstractFileEngine::Refresh); else req |= QAbstractFileEngine::Refresh; QAbstractFileEngine::FileFlags flags = fileEngine->fileFlags(req); fileFlags |= uint(flags); setCachedFlag(cachedFlags); } return fileFlags & request; }
QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const { Q_ASSERT(fileEngine); // should never be called when using the native FS if (!cache_enabled) clearFlags(); uint cf = 0; switch (request) { case QAbstractFileEngine::AccessTime: cf = CachedATime; break; case QAbstractFileEngine::BirthTime: cf = CachedBTime; break; case QAbstractFileEngine::MetadataChangeTime: cf = CachedMCTime; break; case QAbstractFileEngine::ModificationTime: cf = CachedMTime; break; } if (!getCachedFlag(cf)) { fileTimes[request] = fileEngine->fileTime(request); setCachedFlag(cf); } return fileTimes[request]; }
QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const { if (!cache_enabled) clearFlags(); uint cf; if (request == QAbstractFileEngine::CreationTime) cf = CachedCTime; else if (request == QAbstractFileEngine::ModificationTime) cf = CachedMTime; else cf = CachedATime; if (!getCachedFlag(cf)) { fileTimes[request] = fileEngine->fileTime(request); setCachedFlag(cf); } return fileTimes[request]; }
QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const { Q_ASSERT(fileEngine); // should never be called when using the native FS if (!cache_enabled) clearFlags(); uint cf; if (request == QAbstractFileEngine::CreationTime) cf = CachedCTime; else if (request == QAbstractFileEngine::ModificationTime) cf = CachedMTime; else cf = CachedATime; if (!getCachedFlag(cf)) { fileTimes[request] = fileEngine->fileTime(request); setCachedFlag(cf); } return fileTimes[request]; }