Changeset 613 for trunk/src/corelib/io
- Timestamp:
- Feb 27, 2010, 12:25:29 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/io/qfilesystemwatcher.cpp
r602 r613 69 69 QT_BEGIN_NAMESPACE 70 70 71 72 73 74 71 75 class QPollingFileSystemWatcherEngine : public QFileSystemWatcherEngine 72 76 { … … 113 117 mutable QMutex mutex; 114 118 QHash<QString, FileInfo> files, directories; 119 120 121 115 122 116 123 public: … … 162 169 QHash<QString, FileInfo>::iterator x = dit.next(); 163 170 QString path = x.key(); 164 QFileInfo fi(path); 165 if (!path.endsWith(QLatin1Char('/'))) 166 fi = QFileInfo(path + QLatin1Char('/')); 167 if (!fi.exists()) { 168 dit.remove(); 169 emit directoryChanged(path, true); 170 } else if (x.value() != fi) { 171 x.value() = fi; 172 emit directoryChanged(path, false); 171 #if defined(Q_OS_OS2) 172 if (path.isEmpty()) { 173 // check if we got new/changed drives 174 QFileInfoList newDrives = QDir::drives(); 175 if (drives != QDir::drives()) { 176 drives = newDrives; 177 emit directoryChanged(QString::null, false); 178 } 179 } else 180 #endif 181 { 182 QFileInfo fi(path); 183 if (!path.endsWith(QLatin1Char('/'))) 184 fi = QFileInfo(path + QLatin1Char('/')); 185 if (!fi.exists()) { 186 dit.remove(); 187 emit directoryChanged(path, true); 188 } else if (x.value() != fi) { 189 x.value() = fi; 190 emit directoryChanged(path, false); 191 } 173 192 } 174 193 yieldCurrentThread(); … … 195 214 while (it.hasNext()) { 196 215 QString path = it.next(); 197 QFileInfo fi(path); 198 if (!fi.exists()) 199 continue; 200 if (fi.isDir()) { 201 if (!directories->contains(path)) 202 directories->append(path); 203 if (!path.endsWith(QLatin1Char('/'))) 204 fi = QFileInfo(path + QLatin1Char('/')); 205 this->directories.insert(path, fi); 216 #if defined(Q_OS_OS2) 217 if (path.isEmpty()) { 218 // asked to watch for drives 219 if (!directories->contains(DRIVES_ROOT)) 220 directories->append(DRIVES_ROOT); 221 this->directories.insert(DRIVES_ROOT, QFileInfo()); 206 222 startOver = true; 207 } else { 208 if (!files->contains(path)) 209 files->append(path); 210 this->files.insert(path, fi); 211 startOver = true; 223 } else 224 #endif 225 { 226 QFileInfo fi(path); 227 if (!fi.exists()) 228 continue; 229 if (fi.isDir()) { 230 if (!directories->contains(path)) 231 directories->append(path); 232 if (!path.endsWith(QLatin1Char('/'))) 233 fi = QFileInfo(path + QLatin1Char('/')); 234 this->directories.insert(path, fi); 235 startOver = true; 236 } else { 237 if (!files->contains(path)) 238 files->append(path); 239 this->files.insert(path, fi); 240 startOver = true; 241 } 212 242 } 213 243 it.remove(); … … 226 256 while (it.hasNext()) { 227 257 QString path = it.next(); 258 259 260 261 262 263 264 265 266 267 228 268 if (this->directories.remove(path)) { 229 269 directories->removeAll(path); … … 485 525 void QFileSystemWatcher::addPath(const QString &path) 486 526 { 527 487 528 if (path.isEmpty()) { 488 529 qWarning("QFileSystemWatcher::addPath: path is empty"); 489 530 return; 490 531 } 532 491 533 addPaths(QStringList(path)); 492 534 }
Note:
See TracChangeset
for help on using the changeset viewer.