Changeset 613
- Timestamp:
- Feb 27, 2010, 12:25:29 AM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/io/qfilesystemwatcher.cpp
r602 r613 69 69 QT_BEGIN_NAMESPACE 70 70 71 #if defined(Q_OS_OS2) 72 # define DRIVES_ROOT QString::null 73 #endif 74 71 75 class QPollingFileSystemWatcherEngine : public QFileSystemWatcherEngine 72 76 { … … 113 117 mutable QMutex mutex; 114 118 QHash<QString, FileInfo> files, directories; 119 #if defined(Q_OS_OS2) 120 QFileInfoList drives; 121 #endif 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 #if defined(Q_OS_OS2) 259 if (path.isEmpty()) { 260 // asked to stop watching for drives 261 if (this->directories.remove(DRIVES_ROOT)) { 262 directories->removeAll(DRIVES_ROOT); 263 it.remove(); 264 startOver = true; 265 } 266 } else 267 #endif 228 268 if (this->directories.remove(path)) { 229 269 directories->removeAll(path); … … 485 525 void QFileSystemWatcher::addPath(const QString &path) 486 526 { 527 #if !defined(Q_OS_OS2) 487 528 if (path.isEmpty()) { 488 529 qWarning("QFileSystemWatcher::addPath: path is empty"); 489 530 return; 490 531 } 532 #endif 491 533 addPaths(QStringList(path)); 492 534 } -
trunk/src/gui/dialogs/qfileinfogatherer.cpp
r606 r613 302 302 if (files.isEmpty() 303 303 && !watcher->directories().contains(path) 304 #if !defined(Q_OS_OS2) 304 305 && !path.isEmpty() 306 #endif 305 307 && !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) { 306 308 watcher->addPath(path);
Note:
See TracChangeset
for help on using the changeset viewer.