| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qfilesystemwatcher_polling_p.h" | - |
| 43 | #include <QtCore/qtimer.h> | - |
| 44 | | - |
| 45 | #ifndef QT_NO_FILESYSTEMWATCHER | - |
| 46 | | - |
| 47 | QT_BEGIN_NAMESPACE | - |
| 48 | | - |
| 49 | QPollingFileSystemWatcherEngine::QPollingFileSystemWatcherEngine(QObject *parent) | - |
| 50 | : QFileSystemWatcherEngine(parent), | - |
| 51 | timer(this) | - |
| 52 | { | - |
| 53 | connect(&timer, SIGNAL(timeout()), SLOT(timeout())); executed (the execution status of this line is deduced): connect(&timer, "2""timeout()", "1""timeout()"); | - |
| 54 | } executed: }Execution Count:4 | 4 |
| 55 | | - |
| 56 | QStringList QPollingFileSystemWatcherEngine::addPaths(const QStringList &paths, | - |
| 57 | QStringList *files, | - |
| 58 | QStringList *directories) | - |
| 59 | { | - |
| 60 | QStringList p = paths; executed (the execution status of this line is deduced): QStringList p = paths; | - |
| 61 | QMutableListIterator<QString> it(p); executed (the execution status of this line is deduced): QMutableListIterator<QString> it(p); | - |
| 62 | while (it.hasNext()) { evaluated: it.hasNext()| yes Evaluation Count:9 | yes Evaluation Count:9 |
| 9 |
| 63 | QString path = it.next(); executed (the execution status of this line is deduced): QString path = it.next(); | - |
| 64 | QFileInfo fi(path); executed (the execution status of this line is deduced): QFileInfo fi(path); | - |
| 65 | if (!fi.exists()) partially evaluated: !fi.exists()| no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
| 66 | continue; never executed: continue; | 0 |
| 67 | if (fi.isDir()) { evaluated: fi.isDir()| yes Evaluation Count:4 | yes Evaluation Count:5 |
| 4-5 |
| 68 | if (!directories->contains(path)) partially evaluated: !directories->contains(path)| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 69 | directories->append(path); executed: directories->append(path);Execution Count:4 | 4 |
| 70 | if (!path.endsWith(QLatin1Char('/'))) partially evaluated: !path.endsWith(QLatin1Char('/'))| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 71 | fi = QFileInfo(path + QLatin1Char('/')); executed: fi = QFileInfo(path + QLatin1Char('/'));Execution Count:4 | 4 |
| 72 | this->directories.insert(path, fi); executed (the execution status of this line is deduced): this->directories.insert(path, fi); | - |
| 73 | } else { executed: }Execution Count:4 | 4 |
| 74 | if (!files->contains(path)) partially evaluated: !files->contains(path)| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 75 | files->append(path); executed: files->append(path);Execution Count:5 | 5 |
| 76 | this->files.insert(path, fi); executed (the execution status of this line is deduced): this->files.insert(path, fi); | - |
| 77 | } executed: }Execution Count:5 | 5 |
| 78 | it.remove(); executed (the execution status of this line is deduced): it.remove(); | - |
| 79 | } executed: }Execution Count:9 | 9 |
| 80 | | - |
| 81 | if ((!this->files.isEmpty() || evaluated: !this->files.isEmpty()| yes Evaluation Count:5 | yes Evaluation Count:4 |
| 4-5 |
| 82 | !this->directories.isEmpty()) && partially evaluated: !this->directories.isEmpty()| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 83 | !timer.isActive()) { evaluated: !timer.isActive()| yes Evaluation Count:8 | yes Evaluation Count:1 |
| 1-8 |
| 84 | timer.start(PollingInterval); executed (the execution status of this line is deduced): timer.start(PollingInterval); | - |
| 85 | } executed: }Execution Count:8 | 8 |
| 86 | | - |
| 87 | return p; executed: return p;Execution Count:9 | 9 |
| 88 | } | - |
| 89 | | - |
| 90 | QStringList QPollingFileSystemWatcherEngine::removePaths(const QStringList &paths, | - |
| 91 | QStringList *files, | - |
| 92 | QStringList *directories) | - |
| 93 | { | - |
| 94 | QStringList p = paths; executed (the execution status of this line is deduced): QStringList p = paths; | - |
| 95 | QMutableListIterator<QString> it(p); executed (the execution status of this line is deduced): QMutableListIterator<QString> it(p); | - |
| 96 | while (it.hasNext()) { evaluated: it.hasNext()| yes Evaluation Count:5 | yes Evaluation Count:5 |
| 5 |
| 97 | QString path = it.next(); executed (the execution status of this line is deduced): QString path = it.next(); | - |
| 98 | if (this->directories.remove(path)) { evaluated: this->directories.remove(path)| yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
| 99 | directories->removeAll(path); executed (the execution status of this line is deduced): directories->removeAll(path); | - |
| 100 | it.remove(); executed (the execution status of this line is deduced): it.remove(); | - |
| 101 | } else if (this->files.remove(path)) { executed: }Execution Count:1 evaluated: this->files.remove(path)| yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
| 102 | files->removeAll(path); executed (the execution status of this line is deduced): files->removeAll(path); | - |
| 103 | it.remove(); executed (the execution status of this line is deduced): it.remove(); | - |
| 104 | } executed: }Execution Count:3 | 3 |
| 105 | } | - |
| 106 | | - |
| 107 | if (this->files.isEmpty() && partially evaluated: this->files.isEmpty()| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 108 | this->directories.isEmpty()) { evaluated: this->directories.isEmpty()| yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
| 109 | timer.stop(); executed (the execution status of this line is deduced): timer.stop(); | - |
| 110 | } executed: }Execution Count:4 | 4 |
| 111 | | - |
| 112 | return p; executed: return p;Execution Count:5 | 5 |
| 113 | } | - |
| 114 | | - |
| 115 | void QPollingFileSystemWatcherEngine::timeout() | - |
| 116 | { | - |
| 117 | QMutableHashIterator<QString, FileInfo> fit(files); executed (the execution status of this line is deduced): QMutableHashIterator<QString, FileInfo> fit(files); | - |
| 118 | while (fit.hasNext()) { evaluated: fit.hasNext()| yes Evaluation Count:13 | yes Evaluation Count:35 |
| 13-35 |
| 119 | QHash<QString, FileInfo>::iterator x = fit.next(); executed (the execution status of this line is deduced): QHash<QString, FileInfo>::iterator x = fit.next(); | - |
| 120 | QString path = x.key(); executed (the execution status of this line is deduced): QString path = x.key(); | - |
| 121 | QFileInfo fi(path); executed (the execution status of this line is deduced): QFileInfo fi(path); | - |
| 122 | if (!fi.exists()) { evaluated: !fi.exists()| yes Evaluation Count:2 | yes Evaluation Count:11 |
| 2-11 |
| 123 | fit.remove(); executed (the execution status of this line is deduced): fit.remove(); | - |
| 124 | emit fileChanged(path, true); executed (the execution status of this line is deduced): fileChanged(path, true); | - |
| 125 | } else if (x.value() != fi) { executed: }Execution Count:2 evaluated: x.value() != fi| yes Evaluation Count:4 | yes Evaluation Count:7 |
| 2-7 |
| 126 | x.value() = fi; executed (the execution status of this line is deduced): x.value() = fi; | - |
| 127 | emit fileChanged(path, false); executed (the execution status of this line is deduced): fileChanged(path, false); | - |
| 128 | } executed: }Execution Count:4 | 4 |
| 129 | } | - |
| 130 | QMutableHashIterator<QString, FileInfo> dit(directories); executed (the execution status of this line is deduced): QMutableHashIterator<QString, FileInfo> dit(directories); | - |
| 131 | while (dit.hasNext()) { evaluated: dit.hasNext()| yes Evaluation Count:19 | yes Evaluation Count:35 |
| 19-35 |
| 132 | QHash<QString, FileInfo>::iterator x = dit.next(); executed (the execution status of this line is deduced): QHash<QString, FileInfo>::iterator x = dit.next(); | - |
| 133 | QString path = x.key(); executed (the execution status of this line is deduced): QString path = x.key(); | - |
| 134 | QFileInfo fi(path); executed (the execution status of this line is deduced): QFileInfo fi(path); | - |
| 135 | if (!path.endsWith(QLatin1Char('/'))) partially evaluated: !path.endsWith(QLatin1Char('/'))| yes Evaluation Count:19 | no Evaluation Count:0 |
| 0-19 |
| 136 | fi = QFileInfo(path + QLatin1Char('/')); executed: fi = QFileInfo(path + QLatin1Char('/'));Execution Count:19 | 19 |
| 137 | if (!fi.exists()) { evaluated: !fi.exists()| yes Evaluation Count:2 | yes Evaluation Count:17 |
| 2-17 |
| 138 | dit.remove(); executed (the execution status of this line is deduced): dit.remove(); | - |
| 139 | emit directoryChanged(path, true); executed (the execution status of this line is deduced): directoryChanged(path, true); | - |
| 140 | } else if (x.value() != fi) { executed: }Execution Count:2 evaluated: x.value() != fi| yes Evaluation Count:4 | yes Evaluation Count:13 |
| 2-13 |
| 141 | fi.refresh(); executed (the execution status of this line is deduced): fi.refresh(); | - |
| 142 | if (!fi.exists()) { partially evaluated: !fi.exists()| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 143 | dit.remove(); never executed (the execution status of this line is deduced): dit.remove(); | - |
| 144 | emit directoryChanged(path, true); never executed (the execution status of this line is deduced): directoryChanged(path, true); | - |
| 145 | } else { | 0 |
| 146 | x.value() = fi; executed (the execution status of this line is deduced): x.value() = fi; | - |
| 147 | emit directoryChanged(path, false); executed (the execution status of this line is deduced): directoryChanged(path, false); | - |
| 148 | } executed: }Execution Count:4 | 4 |
| 149 | } | - |
| 150 | } | - |
| 151 | } executed: }Execution Count:35 | 35 |
| 152 | | - |
| 153 | QT_END_NAMESPACE | - |
| 154 | #endif // !QT_NO_FILESYSTEMWATCHER | - |
| 155 | | - |
| | |