| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | static QBasicAtomicInt fetchedRoot = { false }; | - |
| 7 | __attribute__((visibility("default"))) void qt_test_resetFetchedRoot() | - |
| 8 | { | - |
| 9 | fetchedRoot.store(false); | - |
| 10 | } | - |
| 11 | | - |
| 12 | __attribute__((visibility("default"))) bool qt_test_isFetchedRoot() | - |
| 13 | { | - |
| 14 | return fetchedRoot.load(); | - |
| 15 | } | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | QFileInfoGatherer::QFileInfoGatherer(QObject *parent) | - |
| 22 | : QThread(parent), abort(false), | - |
| 23 | | - |
| 24 | watcher(0), | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | m_iconProvider(&defaultProvider) | - |
| 30 | { | - |
| 31 | | - |
| 32 | watcher = new QFileSystemWatcher(this); | - |
| 33 | connect(watcher, qFlagLocation("2""directoryChanged(QString)" "\0" __FILE__ ":" "77""83"), this, qFlagLocation("1""list(QString)" "\0" __FILE__ ":" "77""83")); | - |
| 34 | connect(watcher, qFlagLocation("2""fileChanged(QString)" "\0" __FILE__ ":" "78""84"), this, qFlagLocation("1""updateFile(QString)" "\0" __FILE__ ":" "78""84")); | - |
| 35 | | - |
| 36 | start(LowPriority); | - |
| 37 | } | - |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | QFileInfoGatherer::~QFileInfoGatherer() | - |
| 43 | { | - |
| 44 | abort.store(true); | - |
| 45 | QMutexLocker locker(&mutex); | - |
| 46 | condition.wakeAll(); | - |
| 47 | locker.unlock(); | - |
| 48 | wait(); | - |
| 49 | } | - |
| 50 | | - |
| 51 | void QFileInfoGatherer::setResolveSymlinks(bool enable) | - |
| 52 | { | - |
| 53 | (void)enable;; | - |
| 54 | | - |
| 55 | | - |
| 56 | | - |
| 57 | } | - |
| 58 | | - |
| 59 | bool QFileInfoGatherer::resolveSymlinks() const | - |
| 60 | { | - |
| 61 | | - |
| 62 | | - |
| 63 | | - |
| 64 | return false; | - |
| 65 | | - |
| 66 | } | - |
| 67 | | - |
| 68 | void QFileInfoGatherer::setIconProvider(QFileIconProvider *provider) | - |
| 69 | { | - |
| 70 | m_iconProvider = provider; | - |
| 71 | } | - |
| 72 | | - |
| 73 | QFileIconProvider *QFileInfoGatherer::iconProvider() const | - |
| 74 | { | - |
| 75 | return m_iconProvider; | - |
| 76 | } | - |
| 77 | | - |
| 78 | | - |
| 79 | | - |
| 80 | | - |
| 81 | | - |
| 82 | | - |
| 83 | void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStringList &files) | - |
| 84 | { | - |
| 85 | QMutexLocker locker(&mutex); | - |
| 86 | | - |
| 87 | int loc = this->path.lastIndexOf(path); | - |
| 88 | while (loc > 0) { | - |
| 89 | if (this->files.at(loc) == files) { | - |
| 90 | return; | - |
| 91 | } | - |
| 92 | loc = this->path.lastIndexOf(path, loc - 1); | - |
| 93 | } | - |
| 94 | this->path.push(path); | - |
| 95 | this->files.push(files); | - |
| 96 | condition.wakeAll(); | - |
| 97 | | - |
| 98 | | - |
| 99 | if (files.isEmpty() | - |
| 100 | && !path.isEmpty() | - |
| 101 | && !path.startsWith(QLatin1String("//")) ) { | - |
| 102 | if (!watcher->directories().contains(path)) | - |
| 103 | watcher->addPath(path); | - |
| 104 | } | - |
| 105 | | - |
| 106 | } | - |
| 107 | | - |
| 108 | | - |
| 109 | | - |
| 110 | | - |
| 111 | | - |
| 112 | | - |
| 113 | void QFileInfoGatherer::updateFile(const QString &filePath) | - |
| 114 | { | - |
| 115 | QString dir = filePath.mid(0, filePath.lastIndexOf(QDir::separator())); | - |
| 116 | QString fileName = filePath.mid(dir.length() + 1); | - |
| 117 | fetchExtendedInformation(dir, QStringList(fileName)); | - |
| 118 | } | - |
| 119 | | - |
| 120 | | - |
| 121 | | - |
| 122 | | - |
| 123 | | - |
| 124 | | - |
| 125 | void QFileInfoGatherer::clear() | - |
| 126 | { | - |
| 127 | | - |
| 128 | QMutexLocker locker(&mutex); | - |
| 129 | watcher->removePaths(watcher->files()); | - |
| 130 | watcher->removePaths(watcher->directories()); | - |
| 131 | | - |
| 132 | } | - |
| 133 | | - |
| 134 | | - |
| 135 | | - |
| 136 | | - |
| 137 | | - |
| 138 | | - |
| 139 | void QFileInfoGatherer::removePath(const QString &path) | - |
| 140 | { | - |
| 141 | | - |
| 142 | QMutexLocker locker(&mutex); | - |
| 143 | watcher->removePath(path); | - |
| 144 | | - |
| 145 | | - |
| 146 | | - |
| 147 | } | - |
| 148 | | - |
| 149 | | - |
| 150 | | - |
| 151 | | - |
| 152 | | - |
| 153 | | - |
| 154 | void QFileInfoGatherer::list(const QString &directoryPath) | - |
| 155 | { | - |
| 156 | fetchExtendedInformation(directoryPath, QStringList()); | - |
| 157 | } | - |
| 158 | | - |
| 159 | | - |
| 160 | | - |
| 161 | | - |
| 162 | void QFileInfoGatherer::run() | - |
| 163 | { | - |
| 164 | for(;;) { | - |
| 165 | QMutexLocker locker(&mutex); | - |
| 166 | while (!abort.load()| TRUE | never evaluated | | FALSE | never evaluated |
&& path.isEmpty()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 167 | condition.wait(&mutex); never executed: condition.wait(&mutex); | 0 |
| 168 | if (abort.load()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 169 | return; never executed: return; | 0 |
| 170 | const QString thisPath = qAsConst(path.).front(); | - |
| 171 | path.pop_front(); | - |
| 172 | const QStringList thisList = qAsConst(files.).front(); | - |
| 173 | files.pop_front(); | - |
| 174 | locker.unlock(); | - |
| 175 | | - |
| 176 | getFileInfos(thisPath, thisList); | - |
| 177 | } never executed: end of block | 0 |
| 178 | } never executed: end of block | 0 |
| 179 | | - |
| 180 | QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const | - |
| 181 | { | - |
| 182 | QExtendedInformation info(fileInfo); | - |
| 183 | info.icon = m_iconProvider->icon(fileInfo); | - |
| 184 | info.displayType = m_iconProvider->type(fileInfo); | - |
| 185 | return info; | - |
| 186 | } | - |
| 187 | | - |
| 188 | static QString translateDriveName(const QFileInfo &drive) | - |
| 189 | { | - |
| 190 | QString driveName = drive.absoluteFilePath(); | - |
| 191 | | - |
| 192 | | - |
| 193 | | - |
| 194 | | - |
| 195 | | - |
| 196 | | - |
| 197 | return driveName; | - |
| 198 | } | - |
| 199 | | - |
| 200 | | - |
| 201 | | - |
| 202 | | - |
| 203 | | - |
| 204 | void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &files) | - |
| 205 | { | - |
| 206 | | - |
| 207 | if (path.isEmpty()| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 208 | | - |
| 209 | fetchedRoot.store(true); | - |
| 210 | | - |
| 211 | QFileInfoList infoList; | - |
| 212 | if (files.isEmpty()| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 213 | infoList = QDir::drives(); | - |
| 214 | } never executed: end of block else { | 0 |
| 215 | infoList.reserve(files.count()); | - |
| 216 | for (int i = 0; i <const auto &file : files.count(); ++i) | - |
| 217 | infoList << QFileInfo(files.at(i));file); never executed: infoList << QFileInfo(file); | 0 |
| 218 | } never executed: end of block | 0 |
| 219 | for (int i = infoList.count() - 1; i >= 0| TRUE | never evaluated | | FALSE | never evaluated |
; --i) { | 0 |
| 220 | QString driveName = translateDriveName(infoList.at(i)); | - |
| 221 | QVector<QPair<QString,QFileInfo> > updatedFiles; | - |
| 222 | updatedFiles.append(QPair<QString,QFileInfo>(driveName, infoList.at(i))); | - |
| 223 | updates(path, updatedFiles); | - |
| 224 | } never executed: end of block | 0 |
| 225 | return; never executed: return; | 0 |
| 226 | } | - |
| 227 | | - |
| 228 | QElapsedTimer base; | - |
| 229 | base.start(); | - |
| 230 | QFileInfo fileInfo; | - |
| 231 | bool firstTime = true; | - |
| 232 | QVector<QPair<QString, QFileInfo> > updatedFiles; | - |
| 233 | QStringList filesToCheck = files; | - |
| 234 | | - |
| 235 | QString itPath = QDir::fromNativeSeparators(files.isEmpty() ? path : QLatin1String("")); | - |
| 236 | QDirIterator dirIt(itPath, QDir::AllEntries | QDir::System | QDir::Hidden); | - |
| 237 | QStringList allFiles; | - |
| 238 | while (!abort.load()| TRUE | never evaluated | | FALSE | never evaluated |
&& dirIt.hasNext()| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 239 | dirIt.next(); | - |
| 240 | fileInfo = dirIt.fileInfo(); | - |
| 241 | allFiles.append(fileInfo.fileName()); | - |
| 242 | fetch(fileInfo, base, firstTime, updatedFiles, path); | - |
| 243 | } never executed: end of block | 0 |
| 244 | if (!allFiles.isEmpty()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 245 | newListOfFiles(path, allFiles); never executed: newListOfFiles(path, allFiles); | 0 |
| 246 | | - |
| 247 | QStringList::const_iterator filesIt = filesToCheck.constBegin(); | - |
| 248 | while (!abort.load()| TRUE | never evaluated | | FALSE | never evaluated |
&& filesIt != filesToCheck.constEnd()| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 249 | fileInfo.setFile(path + QDir::separator() + *filesIt); | - |
| 250 | ++filesIt; | - |
| 251 | fetch(fileInfo, base, firstTime, updatedFiles, path); | - |
| 252 | } never executed: end of block | 0 |
| 253 | if (!updatedFiles.isEmpty()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 254 | updates(path, updatedFiles); never executed: updates(path, updatedFiles); | 0 |
| 255 | directoryLoaded(path); | - |
| 256 | } never executed: end of block | 0 |
| 257 | | - |
| 258 | void QFileInfoGatherer::fetch(const QFileInfo &fileInfo, QElapsedTimer &base, bool &firstTime, QVector<QPair<QString, QFileInfo> > &updatedFiles, const QString &path) { | - |
| 259 | updatedFiles.append(QPair<QString, QFileInfo>(fileInfo.fileName(), fileInfo)); | - |
| 260 | QElapsedTimer current; | - |
| 261 | current.start(); | - |
| 262 | if ((firstTime && updatedFiles.count() > 100) || base.msecsTo(current) > 1000) { | - |
| 263 | updates(path, updatedFiles); | - |
| 264 | updatedFiles.clear(); | - |
| 265 | base = current; | - |
| 266 | firstTime = false; | - |
| 267 | } | - |
| 268 | } | - |
| 269 | | - |
| 270 | | - |
| 271 | | - |
| 272 | | - |
| 273 | | - |
| | |