Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qfilesystemwatcher_polling.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | - | |||||||
6 | QPollingFileSystemWatcherEngine::QPollingFileSystemWatcherEngine(QObject *parent) | - | ||||||
7 | : QFileSystemWatcherEngine(parent), | - | ||||||
8 | timer(this) | - | ||||||
9 | { | - | ||||||
10 | connect(&timer, qFlagLocation("2""timeout()" "\0" __FILE__ ":" "51"), qFlagLocation("1""timeout()" "\0" __FILE__ ":" "51")); | - | ||||||
11 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
12 | - | |||||||
13 | QStringList QPollingFileSystemWatcherEngine::addPaths(const QStringList &paths, | - | ||||||
14 | QStringList *files, | - | ||||||
15 | QStringList *directories) | - | ||||||
16 | { | - | ||||||
17 | QStringList p = paths; | - | ||||||
18 | QMutableListIterator<QString> it(p); | - | ||||||
19 | while (it.hasNext()
| 9 | ||||||
20 | QString path = it.next(); | - | ||||||
21 | QFileInfo fi(path); | - | ||||||
22 | if (!fi.exists()
| 0-9 | ||||||
23 | continue; never executed: continue; | 0 | ||||||
24 | if (fi.isDir()
| 4-5 | ||||||
25 | if (directories->contains(path)
| 0-4 | ||||||
26 | continue; never executed: continue; | 0 | ||||||
27 | directories->append(path); | - | ||||||
28 | if (!path.endsWith(QLatin1Char('/'))
| 0-4 | ||||||
29 | fi = QFileInfo(path + QLatin1Char('/')); executed 4 times by 1 test: fi = QFileInfo(path + QLatin1Char('/')); Executed by:
| 4 | ||||||
30 | this->directories.insert(path, fi); | - | ||||||
31 | } executed 4 times by 1 test: else {end of block Executed by:
| 4 | ||||||
32 | if (files->contains(path)
| 0-5 | ||||||
33 | continue; never executed: continue; | 0 | ||||||
34 | files->append(path); | - | ||||||
35 | this->files.insert(path, fi); | - | ||||||
36 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||
37 | it.remove(); | - | ||||||
38 | } executed 9 times by 1 test: end of block Executed by:
| 9 | ||||||
39 | - | |||||||
40 | if ((!this->files.isEmpty()
| 4-5 | ||||||
41 | !this->directories.isEmpty()
| 0-4 | ||||||
42 | !timer.isActive()
| 1-8 | ||||||
43 | timer.start(PollingInterval); | - | ||||||
44 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||
45 | - | |||||||
46 | return executed 9 times by 1 test: p;return p; Executed by:
executed 9 times by 1 test: return p; Executed by:
| 9 | ||||||
47 | } | - | ||||||
48 | - | |||||||
49 | QStringList QPollingFileSystemWatcherEngine::removePaths(const QStringList &paths, | - | ||||||
50 | QStringList *files, | - | ||||||
51 | QStringList *directories) | - | ||||||
52 | { | - | ||||||
53 | QStringList p = paths; | - | ||||||
54 | QMutableListIterator<QString> it(p); | - | ||||||
55 | while (it.hasNext()
| 5 | ||||||
56 | QString path = it.next(); | - | ||||||
57 | if (this->directories.remove(path)
| 1-4 | ||||||
58 | directories->removeAll(path); | - | ||||||
59 | it.remove(); | - | ||||||
60 | } executed 1 time by 1 test: else if (this->files.remove(path)end of block Executed by:
| 1-3 | ||||||
61 | files->removeAll(path); | - | ||||||
62 | it.remove(); | - | ||||||
63 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||
64 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||
65 | - | |||||||
66 | if (this->files.isEmpty()
| 0-5 | ||||||
67 | this->directories.isEmpty()
| 1-4 | ||||||
68 | timer.stop(); | - | ||||||
69 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
70 | - | |||||||
71 | return executed 5 times by 1 test: p;return p; Executed by:
executed 5 times by 1 test: return p; Executed by:
| 5 | ||||||
72 | } | - | ||||||
73 | - | |||||||
74 | void QPollingFileSystemWatcherEngine::timeout() | - | ||||||
75 | { | - | ||||||
76 | QMutableHashIterator<QString, FileInfo> fit(files); | - | ||||||
77 | while (fit.hasNext()
| 11-38 | ||||||
78 | QHash<QString, FileInfo>::iterator x = fit.next(); | - | ||||||
79 | QString path = x.key(); | - | ||||||
80 | QFileInfo fi(path); | - | ||||||
81 | if (!fi.exists()
| 2-9 | ||||||
82 | fit.remove(); | - | ||||||
83 | fileChanged(path, true); | - | ||||||
84 | } executed 2 times by 1 test: else if (x.value() != fiend of block Executed by:
| 2-5 | ||||||
85 | x.value() = fi; | - | ||||||
86 | fileChanged(path, false); | - | ||||||
87 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
88 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||
89 | QMutableHashIterator<QString, FileInfo> dit(directories); | - | ||||||
90 | while (dit.hasNext()
| 18-38 | ||||||
91 | QHash<QString, FileInfo>::iterator x = dit.next(); | - | ||||||
92 | QString path = x.key(); | - | ||||||
93 | QFileInfo fi(path); | - | ||||||
94 | if (!path.endsWith(QLatin1Char('/'))
| 0-18 | ||||||
95 | fi = QFileInfo(path + QLatin1Char('/')); executed 18 times by 1 test: fi = QFileInfo(path + QLatin1Char('/')); Executed by:
| 18 | ||||||
96 | if (!fi.exists()
| 2-16 | ||||||
97 | dit.remove(); | - | ||||||
98 | directoryChanged(path, true); | - | ||||||
99 | } executed 2 times by 1 test: else if (x.value() != fiend of block Executed by:
| 2-12 | ||||||
100 | fi.refresh(); | - | ||||||
101 | if (!fi.exists()
| 0-4 | ||||||
102 | dit.remove(); | - | ||||||
103 | directoryChanged(path, true); | - | ||||||
104 | } never executed: else {end of block | 0 | ||||||
105 | x.value() = fi; | - | ||||||
106 | directoryChanged(path, false); | - | ||||||
107 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
108 | } | - | ||||||
109 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||
110 | } executed 38 times by 1 test: end of block Executed by:
| 38 | ||||||
111 | - | |||||||
112 | - | |||||||
Switch to Source code | Preprocessed file |