qfilesystemwatcher_polling.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qfilesystemwatcher_polling.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qfilesystemwatcher_polling_p.h"-
35#include <QtCore/qtimer.h>-
36-
37#ifndef QT_NO_FILESYSTEMWATCHER-
38-
39QT_BEGIN_NAMESPACE-
40-
41QPollingFileSystemWatcherEngine::QPollingFileSystemWatcherEngine(QObject *parent)-
42 : QFileSystemWatcherEngine(parent),-
43 timer(this)-
44{-
45 connect(&timer, SIGNAL(timeout()), SLOT(timeout()));-
46}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
4
47-
48QStringList QPollingFileSystemWatcherEngine::addPaths(const QStringList &paths,-
49 QStringList *files,-
50 QStringList *directories)-
51{-
52 QStringList p = paths;-
53 QMutableListIterator<QString> it(p);-
54 while (it.hasNext()) {
it.hasNext()Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
9
55 QString path = it.next();-
56 QFileInfo fi(path);-
57 if (!fi.exists())
!fi.exists()Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
0-9
58 continue;
never executed: continue;
0
59 if (fi.isDir()) {
fi.isDir()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
4-5
60 if (directories->contains(path))
directories->contains(path)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
0-4
61 continue;
never executed: continue;
0
62 directories->append(path);-
63 if (!path.endsWith(QLatin1Char('/')))
!path.endsWith...tin1Char('/'))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEnever evaluated
0-4
64 fi = QFileInfo(path + QLatin1Char('/'));
executed 4 times by 1 test: fi = QFileInfo(path + QLatin1Char('/'));
Executed by:
  • tst_QFileSystemWatcher
4
65 this->directories.insert(path, fi);-
66 } else {
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
4
67 if (files->contains(path))
files->contains(path)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
0-5
68 continue;
never executed: continue;
0
69 files->append(path);-
70 this->files.insert(path, fi);-
71 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
5
72 it.remove();-
73 }
executed 9 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
9
74-
75 if ((!this->files.isEmpty() ||
!this->files.isEmpty()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
4-5
76 !this->directories.isEmpty()) &&
!this->directories.isEmpty()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEnever evaluated
0-4
77 !timer.isActive()) {
!timer.isActive()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
1-8
78 timer.start(PollingInterval);-
79 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
8
80-
81 return p;
executed 9 times by 1 test: return p;
Executed by:
  • tst_QFileSystemWatcher
9
82}-
83-
84QStringList QPollingFileSystemWatcherEngine::removePaths(const QStringList &paths,-
85 QStringList *files,-
86 QStringList *directories)-
87{-
88 QStringList p = paths;-
89 QMutableListIterator<QString> it(p);-
90 while (it.hasNext()) {
it.hasNext()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
5
91 QString path = it.next();-
92 if (this->directories.remove(path)) {
this->directories.remove(path)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
1-4
93 directories->removeAll(path);-
94 it.remove();-
95 } else if (this->files.remove(path)) {
executed 1 time by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
this->files.remove(path)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
1-3
96 files->removeAll(path);-
97 it.remove();-
98 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
3
99 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
5
100-
101 if (this->files.isEmpty() &&
this->files.isEmpty()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEnever evaluated
0-5
102 this->directories.isEmpty()) {
this->directories.isEmpty()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
1-4
103 timer.stop();-
104 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
4
105-
106 return p;
executed 5 times by 1 test: return p;
Executed by:
  • tst_QFileSystemWatcher
5
107}-
108-
109void QPollingFileSystemWatcherEngine::timeout()-
110{-
111 QMutableHashIterator<QString, FileInfo> fit(files);-
112 while (fit.hasNext()) {
fit.hasNext()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
12-38
113 QHash<QString, FileInfo>::iterator x = fit.next();-
114 QString path = x.key();-
115 QFileInfo fi(path);-
116 if (!fi.exists()) {
!fi.exists()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
2-10
117 fit.remove();-
118 emit fileChanged(path, true);-
119 } else if (x.value() != fi) {
executed 2 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
x.value() != fiDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
2-6
120 x.value() = fi;-
121 emit fileChanged(path, false);-
122 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
4
123 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
12
124 QMutableHashIterator<QString, FileInfo> dit(directories);-
125 while (dit.hasNext()) {
dit.hasNext()Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
17-38
126 QHash<QString, FileInfo>::iterator x = dit.next();-
127 QString path = x.key();-
128 QFileInfo fi(path);-
129 if (!path.endsWith(QLatin1Char('/')))
!path.endsWith...tin1Char('/'))Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEnever evaluated
0-17
130 fi = QFileInfo(path + QLatin1Char('/'));
executed 17 times by 1 test: fi = QFileInfo(path + QLatin1Char('/'));
Executed by:
  • tst_QFileSystemWatcher
17
131 if (!fi.exists()) {
!fi.exists()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
2-15
132 dit.remove();-
133 emit directoryChanged(path, true);-
134 } else if (x.value() != fi) {
executed 2 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
x.value() != fiDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
2-11
135 fi.refresh();-
136 if (!fi.exists()) {
!fi.exists()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
0-4
137 dit.remove();-
138 emit directoryChanged(path, true);-
139 } else {
never executed: end of block
0
140 x.value() = fi;-
141 emit directoryChanged(path, false);-
142 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
4
143 }-
144 }
executed 17 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
17
145}
executed 38 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
38
146-
147QT_END_NAMESPACE-
148#endif // !QT_NO_FILESYSTEMWATCHER-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9