48 #include <io/config-kdirwatch.h>
54 #include <QtCore/QDir>
55 #include <QtCore/QFile>
56 #include <QtCore/QSocketNotifier>
57 #include <QtCore/QTimer>
58 #include <QtCore/QCoreApplication>
71 #include <sys/ioctl.h>
74 #include <sys/utsname.h>
89 if (method == QLatin1String(
"Fam")) {
91 }
else if (method == QLatin1String(
"Stat")) {
93 }
else if (method == QLatin1String(
"QFSWatch")) {
158 delayRemove( false ),
162 timer.setObjectName(QLatin1String(
"KDirWatchPrivate::timer"));
177 availableMethods <<
"Stat";
180 rescan_timer.setObjectName(QString::fromLatin1(
"KDirWatchPrivate::rescan_timer"));
186 if (FAMOpen(&fc) ==0) {
187 availableMethods <<
"FAM";
189 sn =
new QSocketNotifier( FAMCONNECTION_GETFD(&fc),
190 QSocketNotifier::Read,
this);
191 connect( sn, SIGNAL(activated(
int)),
195 kDebug(7001) <<
"Can't use FAM (fam daemon not running?)";
200 #ifdef HAVE_SYS_INOTIFY_H
201 supports_inotify =
true;
203 m_inotify_fd = inotify_init();
205 if ( m_inotify_fd <= 0 ) {
206 kDebug(7001) <<
"Can't use Inotify, kernel doesn't support it";
207 supports_inotify =
false;
212 int major, minor, patch;
213 if (uname(&uts) < 0) {
214 supports_inotify =
false;
215 kDebug(7001) <<
"Unable to get uname";
216 }
else if (sscanf(uts.release,
"%d.%d", &major, &minor) != 2) {
217 supports_inotify =
false;
218 kDebug(7001) <<
"The version is malformed: " << uts.release;
219 }
else if(major == 2 && minor == 6) {
220 if (sscanf(uts.release,
"%d.%d.%d", &major, &minor, &patch) != 3) {
221 supports_inotify =
false;
222 kDebug() <<
"Detected 2.6 kernel but can't know more: " << uts.release;
223 }
else if (major * 1000000 + minor * 1000 + patch < 2006014 ){
224 supports_inotify =
false;
225 kDebug(7001) <<
"Can't use INotify, Linux kernel too old " << uts.release;
230 kDebug(7001) <<
"INotify available: " << supports_inotify;
231 if ( supports_inotify ) {
232 availableMethods <<
"INotify";
233 (void)fcntl(m_inotify_fd, F_SETFD, FD_CLOEXEC);
235 mSn =
new QSocketNotifier( m_inotify_fd, QSocketNotifier::Read,
this );
236 connect( mSn, SIGNAL(activated(
int)),
240 #ifdef HAVE_QFILESYSTEMWATCHER
241 availableMethods <<
"QFileSystemWatcher";
262 #ifdef HAVE_SYS_INOTIFY_H
263 if ( supports_inotify )
264 ::close( m_inotify_fd );
266 #ifdef HAVE_QFILESYSTEMWATCHER
274 #ifdef HAVE_SYS_INOTIFY_H
275 if ( !supports_inotify )
279 int offsetStartRead = 0;
281 assert( m_inotify_fd > -1 );
282 ioctl( m_inotify_fd, FIONREAD, &pending );
284 while ( pending > 0 ) {
286 const int bytesToRead = qMin( pending, (
int)
sizeof( buf ) - offsetStartRead );
288 int bytesAvailable = read( m_inotify_fd, &buf[offsetStartRead], bytesToRead );
289 pending -= bytesAvailable;
290 bytesAvailable += offsetStartRead;
293 int offsetCurrent = 0;
294 while ( bytesAvailable >= (
int)
sizeof(
struct inotify_event ) ) {
295 const struct inotify_event *
const event = (
struct inotify_event *) &buf[offsetCurrent];
296 const int eventSize =
sizeof(
struct inotify_event ) + event->len;
297 if ( bytesAvailable < eventSize ) {
301 bytesAvailable -= eventSize;
302 offsetCurrent += eventSize;
305 QByteArray cpath(event->name, event->len);
307 path = QFile::decodeName ( cpath );
319 if ( e->wd == event->wd ) {
326 if( event->mask & IN_DELETE_SELF) {
327 if (s_verboseDebug) {
328 kDebug(7001) <<
"-->got deleteself signal for" << e->
path;
337 parentEntry->
dirty =
true;
341 if ( event->mask & IN_IGNORED ) {
345 if ( event->mask & (IN_CREATE|IN_MOVED_TO) ) {
346 const QString tpath = e->
path + QLatin1Char(
'/') + path;
349 if (s_verboseDebug) {
350 kDebug(7001) <<
"-->got CREATE signal for" << (tpath) <<
"sub_entry=" << sub_entry;
357 sub_entry->
dirty =
true;
362 Q_FOREACH(
Client *client, clients) {
370 if (!clients.isEmpty()) {
372 kDebug(7001).nospace() << clients.count() <<
" instance(s) monitoring the new "
373 << (isDir ?
"dir " :
"file ") << tpath;
375 e->m_pendingFileChanges.append(e->
path);
380 if (event->mask & (IN_DELETE|IN_MOVED_FROM)) {
381 const QString tpath = e->
path + QLatin1Char(
'/') + path;
382 if (s_verboseDebug) {
383 kDebug(7001) <<
"-->got DELETE signal for" << tpath;
391 KDE_struct_stat stat_buf;
396 bool isDir = S_ISDIR(stat_buf.st_mode);
410 if (event->mask & (IN_MODIFY|IN_ATTRIB)) {
412 const QString tpath = e->
path + QLatin1Char(
'/') + path;
413 if (s_verboseDebug) {
414 kDebug(7001) <<
"-->got MODIFY signal for" << (tpath);
431 e->m_pendingFileChanges.append(tpath);
442 if (bytesAvailable > 0) {
444 memmove(buf, &buf[offsetCurrent], bytesAvailable);
445 offsetStartRead = bytesAvailable;
459 if (!sub_entry->
dirty)
461 sub_entry->
dirty =
true;
472 KDirWatch::WatchModes watchModes)
477 foreach(
Client* client, m_clients) {
492 m_clients.append(client);
499 for ( ; it != end ; ++it ) {
503 if (client->
count == 0) {
516 foreach(
Client* client, m_clients)
517 clients += client->
count;
524 return QDir::cleanPath(path + QLatin1String(
"/.."));
530 KDE_struct_stat stat_buf;
532 *isDir = S_ISDIR(stat_buf.st_mode);
533 const KDirWatch::WatchModes flag =
535 Q_FOREACH(
Client *client, this->m_clients) {
551 debug.nospace() <<
"[ Entry for " << entry.
path <<
", " << (entry.
isDir ?
"dir" :
"file");
553 debug <<
", non-existent";
559 #ifdef HAVE_SYS_INOTIFY_H
561 debug <<
" inotify_wd=" << entry.wd;
563 debug <<
", has " << entry.
m_clients.count() <<
" clients";
566 debug <<
", nonexistent subentries:";
568 debug << subEntry << subEntry->
path;
577 if (_path.isEmpty() || QDir::isRelativePath(_path)) {
583 if ( path.length() > 1 && path.endsWith( QLatin1Char(
'/' ) ) )
584 path.truncate( path.length() - 1 );
602 kDebug(7001) <<
"Global Poll Freq is now" <<
freq <<
"msec";
607 #if defined(HAVE_FAM)
609 bool KDirWatchPrivate::useFAM(Entry* e)
611 if (!use_fam)
return false;
623 addEntry(0, e->parentDirectory(), e,
true);
626 int res =FAMMonitorDirectory(&fc, QFile::encodeName(e->path),
634 kDebug(7001).nospace() <<
" Setup FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr))
635 <<
") for " << e->path;
641 addEntry(0, QFileInfo(e->path).absolutePath(), e,
true);
644 int res = FAMMonitorFile(&fc, QFile::encodeName(e->path),
653 kDebug(7001).nospace() <<
" Setup FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr))
654 <<
") for " << e->path;
666 #ifdef HAVE_SYS_INOTIFY_H
668 bool KDirWatchPrivate::useINotify( Entry* e )
675 if (!supports_inotify)
return false;
680 addEntry(0, e->parentDirectory(), e,
true);
685 int mask = IN_DELETE|IN_DELETE_SELF|IN_CREATE|IN_MOVE|IN_MOVE_SELF|IN_DONT_FOLLOW|IN_MOVED_FROM|IN_MODIFY|IN_ATTRIB;
687 if ( ( e->wd = inotify_add_watch( m_inotify_fd,
688 QFile::encodeName( e->path ), mask) ) >= 0)
690 if (s_verboseDebug) {
691 kDebug(7001) <<
"inotify successfully used for monitoring" << e->path <<
"wd=" << e->wd;
696 kDebug(7001) <<
"inotify failed for monitoring" << e->path <<
":" << strerror(errno);
700 #ifdef HAVE_QFILESYSTEMWATCHER
711 kDebug(7001) <<
"fsWatcher->addPath" << e->
path;
736 kDebug(7001) <<
" Started Polling Timer, freq " <<
freq;
740 kDebug(7001) <<
" Setup Stat (freq " << e->
freq <<
") for " << e->
path;
752 Entry* sub_entry,
bool isDir, KDirWatch::WatchModes watchModes)
757 || path == QLatin1String(
"/dev")
758 || (path.startsWith(QLatin1String(
"/dev/")) && !path.startsWith(QLatin1String(
"/dev/.")))
763 if ( path.length() > 1 && path.endsWith( QLatin1Char(
'/' ) ) )
764 path.truncate( path.length() - 1 );
770 (*it).m_entries.append(sub_entry);
771 if (s_verboseDebug) {
772 kDebug(7001) <<
"Added already watched Entry" << path
773 <<
"(for" << sub_entry->
path <<
")";
775 #ifdef HAVE_SYS_INOTIFY_H
778 int mask = IN_DELETE|IN_DELETE_SELF|IN_CREATE|IN_MOVE|IN_MOVE_SELF|IN_DONT_FOLLOW;
780 mask |= IN_MODIFY|IN_ATTRIB;
784 inotify_rm_watch (m_inotify_fd, e->wd);
785 e->wd = inotify_add_watch( m_inotify_fd, QFile::encodeName( e->
path ),
792 (*it).addClient(instance, watchModes);
793 if (s_verboseDebug) {
794 kDebug(7001) <<
"Added already watched Entry" << path
795 <<
"(now" << (*it).clientCount() <<
"clients)"
796 << QString::fromLatin1(
"[%1]").arg(instance->objectName());
804 KDE_struct_stat stat_buf;
805 bool exists = (
KDE::stat(path, &stat_buf) == 0);
809 Entry* e = &(*newIt);
812 e->
isDir = S_ISDIR(stat_buf.st_mode);
814 if (e->
isDir && !isDir) {
816 if (S_ISLNK(stat_buf.st_mode))
820 qWarning() <<
"KDirWatch:" << path <<
"is a directory. Use addDir!";
822 }
else if (!e->
isDir && isDir)
823 qWarning(
"KDirWatch: %s is a file. Use addFile!", qPrintable(path));
826 qWarning() <<
"KDirWatch:" << path <<
"is a file. You can't use recursive or "
827 "watchFiles options";
833 e->
m_ctime = stat_buf.st_mtime;
835 e->
m_ctime = stat_buf.st_ctime;
838 e->
m_nlink = stat_buf.st_nlink;
839 e->
m_ino = stat_buf.st_ino;
855 kDebug(7001).nospace() <<
"Added " << (e->
isDir ?
"Dir " :
"File ") << path
857 <<
" for " << (sub_entry ? sub_entry->
path :
QString())
858 <<
" [" << (instance ? instance->objectName() :
QString()) <<
"]";
868 QFlags<QDir::Filter> filters = QDir::NoDotAndDotDot;
872 filters |= (QDir::Dirs|QDir::Files);
873 }
else if (watchModes & KDirWatch::WatchSubDirs) {
874 filters |= QDir::Dirs;
876 filters |= QDir::Files;
879 #if defined(HAVE_SYS_INOTIFY_H)
886 filters &= ~QDir::Files;
890 QDir basedir (e->
path);
891 const QFileInfoList contents = basedir.entryInfoList(filters);
892 for (QFileInfoList::const_iterator iter = contents.constBegin();
893 iter != contents.constEnd(); ++iter)
895 const QFileInfo &fileInfo = *iter;
897 bool isDir = fileInfo.isDir() && !fileInfo.isSymLink();
899 addEntry (instance, fileInfo.absoluteFilePath(), 0, isDir,
925 bool entryAdded =
false;
926 switch (preferredMethod) {
927 #if defined(HAVE_FAM)
930 #if defined(HAVE_SYS_INOTIFY_H)
933 #if defined(HAVE_QFILESYSTEMWATCHER)
942 #if defined(HAVE_SYS_INOTIFY_H)
943 if (useINotify(e))
return;
945 #if defined(HAVE_FAM)
946 if (useFAM(e))
return;
948 #if defined(HAVE_QFILESYSTEMWATCHER)
959 FAMCancelMonitor(&fc, &(e->fr) );
960 kDebug(7001).nospace() <<
"Cancelled FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr))
961 <<
") for " << e->
path;
964 #ifdef HAVE_SYS_INOTIFY_H
966 (void) inotify_rm_watch( m_inotify_fd, e->wd );
967 if (s_verboseDebug) {
968 kDebug(7001).nospace() <<
"Cancelled INotify (fd " << m_inotify_fd <<
", "
969 << e->wd <<
") for " << e->
path;
973 #ifdef HAVE_QFILESYSTEMWATCHER
976 kDebug(7001) <<
"fsWatcher->removePath" << e->
path;
986 if (s_verboseDebug) {
987 kDebug(7001) <<
"path=" << _path <<
"sub_entry:" << sub_entry;
991 kWarning(7001) <<
"doesn't know" << _path;
1032 kDebug(7001) <<
" Stopped Polling Timer";
1036 if (s_verboseDebug) {
1037 kDebug(7001).nospace() <<
"Removed " << (e->
isDir ?
"Dir ":
"File ") << e->
path
1038 <<
" for " << (sub_entry ? sub_entry->
path :
QString())
1039 <<
" [" << (instance ? instance->objectName() :
QString()) <<
"]";
1050 int minfreq = 3600000;
1057 foreach(
Client* client, (*it).m_clients) {
1058 if (client->
instance == instance) {
1065 pathList.append((*it).path);
1067 else if ( (*it).m_mode ==
StatMode && (*it).freq < minfreq )
1068 minfreq = (*it).freq;
1071 foreach(
const QString &path, pathList)
1074 if (minfreq >
freq) {
1078 kDebug(7001) <<
"Poll Freq now" <<
freq <<
"msec";
1085 int stillWatching = 0;
1087 if (!instance || instance == client->
instance)
1090 stillWatching += client->
count;
1093 kDebug(7001) << (instance ? instance->objectName() : QString::fromLatin1(
"all"))
1094 <<
"stopped scanning" << e->
path <<
"(now"
1095 << stillWatching <<
"watchers)";
1097 if (stillWatching == 0) {
1112 int wasWatching = 0, newWatching = 0;
1115 wasWatching += client->
count;
1116 else if (!instance || instance == client->
instance) {
1118 newWatching += client->
count;
1121 if (newWatching == 0)
1124 kDebug(7001) << (instance ? instance->objectName() : QString::fromLatin1(
"all"))
1125 <<
"restarted scanning" << e->
path
1126 <<
"(now" << wasWatching+newWatching <<
"watchers)";
1131 if (wasWatching == 0) {
1133 KDE_struct_stat stat_buf;
1138 e->
m_ctime = stat_buf.st_mtime;
1140 e->
m_ctime = stat_buf.st_ctime;
1143 if (s_verboseDebug) {
1144 kDebug(7001) <<
"Setting status to Normal for" << e << e->
path;
1146 e->
m_nlink = stat_buf.st_nlink;
1147 e->
m_ino = stat_buf.st_ino;
1156 if (s_verboseDebug) {
1157 kDebug(7001) <<
"Setting status to NonExistent for" << e << e->
path;
1179 bool notify,
bool skippedToo )
1198 foreach(
Client* client, (*it).m_clients) {
1228 KDE_struct_stat stat_buf;
1235 e->
m_ctime = qMax(stat_buf.st_ctime, stat_buf.st_mtime);
1237 e->
m_ino = stat_buf.st_ino;
1238 if (s_verboseDebug) {
1239 kDebug(7001) <<
"Setting status to Normal for just created" << e << e->
path;
1247 #if 1 // for debugging the if() below
1248 if (s_verboseDebug) {
1249 struct tm* tmp = localtime(&e->
m_ctime);
1251 strftime(outstr,
sizeof(outstr),
"%T", tmp);
1253 <<
"stat_buf.st_ctime=" << stat_buf.st_ctime
1254 <<
"e->m_nlink=" << e->
m_nlink
1255 <<
"stat_buf.st_nlink=" << stat_buf.st_nlink
1256 <<
"e->m_ino=" << e->
m_ino
1257 <<
"stat_buf.st_ino=" << stat_buf.st_ino;
1262 (qMax(stat_buf.st_ctime, stat_buf.st_mtime) != e->
m_ctime ||
1263 stat_buf.st_ino != e->
m_ino ||
1264 stat_buf.st_nlink != nlink_t(e->
m_nlink)))
1272 e->
m_ctime = qMax(stat_buf.st_ctime, stat_buf.st_mtime);
1273 e->
m_nlink = stat_buf.st_nlink;
1274 if (e->
m_ino != stat_buf.st_ino) {
1279 e->
m_ino = stat_buf.st_ino;
1307 if (!fileName.isEmpty()) {
1308 if (!QDir::isRelativePath(fileName))
1312 path += QLatin1Char(
'/') + fileName;
1313 #elif defined(Q_WS_WIN)
1315 path += QDir::currentPath().left(2) + QLatin1Char(
'/') + fileName;
1320 if (s_verboseDebug) {
1345 QMetaObject::invokeMethod(c->
instance,
"setDeleted", Qt::QueuedConnection, Q_ARG(
QString, path));
1351 QMetaObject::invokeMethod(c->
instance,
"setCreated", Qt::QueuedConnection, Q_ARG(
QString, path));
1356 QMetaObject::invokeMethod(c->
instance,
"setDirty", Qt::QueuedConnection, Q_ARG(
QString, path));
1382 EntryMap::Iterator it;
1388 bool timerRunning =
timer.isActive();
1411 (*it).propagate_dirty();
1414 #ifdef HAVE_SYS_INOTIFY_H
1422 if (!entry->
isValid())
continue;
1426 kDebug(7001) <<
"scanEntry for" << entry->
path <<
"says" << ev;
1429 #ifdef HAVE_SYS_INOTIFY_H
1433 kDebug(7001) <<
"scanEntry says" << entry->
path <<
"was deleted";
1437 kDebug(7001) <<
"scanEntry says" << entry->
path <<
"was created. wd=" << entry->wd;
1438 if (entry->wd < 0) {
1439 cList.append(entry);
1456 #ifdef HAVE_SYS_INOTIFY_H
1462 QStringList pendingFileChanges = entry->m_pendingFileChanges;
1463 pendingFileChanges.removeDuplicates();
1464 Q_FOREACH(
const QString &changedFilename, pendingFileChanges) {
1465 if (s_verboseDebug) {
1466 kDebug(7001) <<
"processing pending file change for" << changedFilename;
1470 entry->m_pendingFileChanges.clear();
1482 #ifdef HAVE_SYS_INOTIFY_H
1484 Q_FOREACH(
Entry* e, cList)
1494 if ( *filename ==
'.') {
1495 if (strncmp(filename,
".X.err", 6) == 0)
return true;
1496 if (strncmp(filename,
".xsession-errors", 16) == 0)
return true;
1499 if (strncmp(filename,
".fonts.cache", 12) == 0)
return true;
1514 while(use_fam && FAMPending(&fc)) {
1515 if (FAMNextEvent(&fc, &fe) == -1) {
1516 kWarning(7001) <<
"FAM connection problem, switching to polling.";
1523 if ((*it).m_mode ==
FAMMode && (*it).m_clients.count()>0) {
1535 void KDirWatchPrivate::checkFAMEvent(FAMEvent* fe)
1540 if ((fe->code == FAMExists) ||
1541 (fe->code == FAMEndExist) ||
1542 (fe->code == FAMAcknowledge))
return;
1550 if (FAMREQUEST_GETREQNUM(&( (*it).fr )) ==
1551 FAMREQUEST_GETREQNUM(&(fe->fr)) ) {
1558 if (s_verboseDebug) {
1559 kDebug(7001) <<
"Processing FAM event ("
1560 << ((fe->code == FAMChanged) ?
"FAMChanged" :
1561 (fe->code == FAMDeleted) ?
"FAMDeleted" :
1562 (fe->code == FAMStartExecuting) ?
"FAMStartExecuting" :
1563 (fe->code == FAMStopExecuting) ?
"FAMStopExecuting" :
1564 (fe->code == FAMCreated) ?
"FAMCreated" :
1565 (fe->code == FAMMoved) ?
"FAMMoved" :
1566 (fe->code == FAMAcknowledge) ?
"FAMAcknowledge" :
1567 (fe->code == FAMExists) ?
"FAMExists" :
1568 (fe->code == FAMEndExist) ?
"FAMEndExist" :
"Unknown Code")
1569 <<
", " << fe->filename
1570 <<
", Req " << FAMREQUEST_GETREQNUM(&(fe->fr)) <<
") e=" << e;
1580 kDebug(7001) <<
"FAM event for nonExistent entry " << e->path;
1593 if (!QDir::isRelativePath(QFile::decodeName(fe->filename))) {
1594 FAMCancelMonitor(&fc, &(e->fr) );
1595 kDebug(7001) <<
"Cancelled FAMReq"
1596 << FAMREQUEST_GETREQNUM(&(e->fr))
1597 <<
"for" << e->path;
1602 Entry* parentEntry =
entry(e->parentDirectory());
1604 parentEntry->
dirty =
true;
1606 addEntry(0, e->parentDirectory(), e,
true );
1617 QString tpath(e->path + QLatin1Char(
'/') + QFile::decodeName(fe->filename));
1620 Entry* sub_entry = e->findSubEntry(tpath);
1624 sub_entry->dirty =
true;
1626 }
else if (e->isDir && !e->m_clients.empty()) {
1628 const QList<Client *> clients = e->clientsForFileOrDir(tpath, &isDir);
1629 Q_FOREACH(Client *client, clients) {
1630 addEntry (client->instance, tpath, 0, isDir,
1634 if (!clients.isEmpty()) {
1637 kDebug(7001).nospace() << clients.count() <<
" instance(s) monitoring the new "
1638 << (isDir ?
"dir " :
"file ") << tpath;
1650 kWarning (7001) <<
"Fam event received but FAM is not supported";
1657 EntryMap::Iterator it;
1659 kDebug(7001) <<
"Entries watched:";
1661 kDebug(7001) <<
" None.";
1667 kDebug(7001) <<
" " << *e;
1675 if (!pending.isEmpty()) pending =
" (pending: " + pending +
')';
1676 pending =
", stopped" + pending;
1679 <<
" (" << c->
count <<
" times)" << pending;
1682 kDebug(7001) <<
" dependent entries:";
1685 if (s_verboseDebug) {
1694 #ifdef HAVE_QFILESYSTEMWATCHER
1706 kDebug(7001) <<
"scanEntry for" << e->
path <<
"says" << ev;
1713 addEntry(0, QFileInfo(e->
path).absolutePath(), e,
true);
1717 }
else if (e->
isDir) {
1729 kWarning (7001) <<
"QFileSystemWatcher event received but QFileSystemWatcher is not supported";
1731 #endif // HAVE_QFILESYSTEMWATCHER
1740 return s_pKDirWatchSelf;
1746 return s_pKDirWatchSelf.exists();
1751 s_pKDirWatchSelf->deleteQFSWatcher();
1757 static int nameCounter = 0;
1760 setObjectName(QString::fromLatin1(
"KDirWatch-%1").arg(nameCounter) );
1766 static bool cleanupRegistered =
false;
1767 if (!cleanupRegistered) {
1768 cleanupRegistered =
true;
1787 if (d) d->
addEntry(
this, _path, 0,
true, watchModes);
1795 d->
addEntry(
this, _path, 0,
false);
1883 kDebug(7001) <<
"KDirWatch not used";
1892 kDebug(7001) << objectName() <<
"emitting created" << _file;
1899 emit
dirty( _file );
1904 kDebug(7001) << objectName() <<
"emitting deleted" << _file;
1914 #include "kdirwatch.moc"
1915 #include "kdirwatch_p.moc"
void removeEntry(KDirWatch *, const QString &, Entry *sub_entry)
QString parentDirectory() const
static const char * methodToString(KDirWatch::Method method)
static KDirWatchPrivate * createPrivate()
QList< Client * > clientsForFileOrDir(const QString &tpath, bool *isDir) const
void setCreated(const QString &path)
Emits created().
void addFile(const QString &file)
Adds a file to be watched.
QList< Client * > m_clients
void useFreq(Entry *e, int newFreq)
static bool isNoisyFile(const char *filename)
KDirWatch(QObject *parent=0)
Constructor.
void stopScan()
Stops scanning of all directories in internal list.
Watch just the specified directory.
void stopScan(KDirWatch *)
bool stopEntryScan(KDirWatch *, Entry *)
static QDateTime fromTime_t(qint32 seconds)
#define K_GLOBAL_STATIC(TYPE, NAME)
This macro makes it easy to use non-POD types as global statics.
void startScan(bool notify=false, bool skippedToo=false)
Starts scanning of all dirs in list.
Method internalMethod()
Returns the preferred internal method to watch for changes.
int stat(const QString &path, KDE_struct_stat *buf)
bool restartEntryScan(KDirWatch *, Entry *, bool)
QList< Entry * > m_entries
void removeEntries(KDirWatch *)
KDirWatch::WatchModes m_watchModes
void removePath(const QString &file)
Type fileSystemType(const QString &path)
KSharedConfigPtr config()
Returns the general config object.
bool stopDirScan(const QString &path)
Stops scanning the specified path.
void deleted(const QString &path)
Emitted when a file or directory is deleted.
void resetList(KDirWatch *, bool)
bool useQFSWatch(Entry *e)
void emitEvent(const Entry *e, int event, const QString &fileName=QString())
KDirWatch::Method m_preferredMethod
KDirWatch::Method m_nfsPreferredMethod
static void statistics()
Dump statistic information about the KDirWatch::self() instance.
KFileSystemWatcher * fsWatcher
void fswEventReceived(const QString &path)
void setDeleted(const QString &path)
Emits deleted().
void removeWatch(Entry *entry)
static KDirWatchPrivate * dwp_self
QDateTime ctime(const QString &path) const
Returns the time the directory/file was last changed.
void created(const QString &path)
Emitted when a file or directory is created.
void startScan(KDirWatch *, bool, bool)
int lstat(const QString &path, KDE_struct_stat *buf)
Watch also all files contained by the directory.
bool contains(const QString &path) const
Check if a directory is being watched by this KDirWatch instance.
A class for one specific group in a KConfig object.
void inotifyEventReceived()
static void cleanupQFSWatcher()
void removeClient(KDirWatch *)
QSet< Entry * > removeList
void addPath(const QString &file)
void removeDir(const QString &path)
Removes a directory from the list of scanned directories.
void addDir(const QString &path, WatchModes watchModes=WatchDirOnly)
Adds a directory to be watched.
Entry * entry(const QString &)
static bool exists()
Returns true if there is an instance of KDirWatch.
Class for watching directory and file changes.
void dirty(const QString &path)
Emitted when a watched object is changed.
Watch also all the subdirs contained by the directory.
void setDirty(const QString &path)
Emits dirty().
bool isStopped()
Is scanning stopped? After creation of a KDirWatch instance, this is false.
void removeFile(const QString &file)
Removes a file from the list of watched files.
Entry * findSubEntry(const QString &path) const
static KDirWatch::Method methodFromString(const QString &method)
T readEntry(const QString &key, const T &aDefault) const
Reads the value of an entry specified by pKey in the current group.
void addClient(KDirWatch *, KDirWatch::WatchModes)
void addEntry(KDirWatch *instance, const QString &_path, Entry *sub_entry, bool isDir, KDirWatch::WatchModes watchModes=KDirWatch::WatchDirOnly)
bool restartDirScan(const QString &path)
Restarts scanning for specified path.
QDataStream & operator<<(QDataStream &d, const ActionReply &reply)
void addWatch(Entry *entry)
static const bool s_verboseDebug