48#include <io/config-kdirwatch.h>
55#include <QtCore/QFile>
56#include <QtCore/QSocketNotifier>
57#include <QtCore/QTimer>
58#include <QtCore/QCoreApplication>
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"));
169 QString method = config.readEntry(
"PreferredMethod",
"inotify");
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 );
313 const bool isDir = (
event->mask & (IN_ISDIR));
323 if ( e->wd == event->wd ) {
324 const bool wasDirty = e->
dirty;
327 const QString tpath = e->
path + QLatin1Char(
'/') + path;
333 if( event->mask & IN_DELETE_SELF) {
335 kDebug(7001) <<
"-->got deleteself signal for" << e->
path;
344 parentEntry->
dirty =
true;
348 if ( event->mask & IN_IGNORED ) {
352 if ( event->mask & (IN_CREATE|IN_MOVED_TO) ) {
356 kDebug(7001) <<
"-->got CREATE signal for" << (tpath) <<
"sub_entry=" << sub_entry;
363 sub_entry->
dirty =
true;
367 Q_FOREACH(
Client *client, clients) {
375 if (!clients.isEmpty()) {
377 kDebug(7001).nospace() << clients.count() <<
" instance(s) monitoring the new "
378 << (isDir ?
"dir " :
"file ") << tpath;
380 e->m_pendingFileChanges.append(e->
path);
385 if (event->mask & (IN_DELETE|IN_MOVED_FROM)) {
387 kDebug(7001) <<
"-->got DELETE signal for" << tpath;
407 if (event->mask & (IN_MODIFY|IN_ATTRIB)) {
410 kDebug(7001) <<
"-->got MODIFY signal for" << (tpath);
427 e->m_pendingFileChanges.append(tpath);
429 e->
dirty = (wasDirty || (path.isEmpty() && (
event->mask & IN_ATTRIB)));
440 if (bytesAvailable > 0) {
442 memmove(buf, &buf[offsetCurrent], bytesAvailable);
443 offsetStartRead = bytesAvailable;
457 if (!sub_entry->
dirty)
459 sub_entry->
dirty =
true;
470 KDirWatch::WatchModes watchModes)
475 foreach(
Client* client, m_clients) {
490 m_clients.append(client);
497 for ( ; it != end ; ++it ) {
501 if (client->
count == 0) {
514 foreach(
Client* client, m_clients)
515 clients += client->
count;
522 return QDir::cleanPath(path + QLatin1String(
"/.."));
528 KDE_struct_stat stat_buf;
530 *isDir = S_ISDIR(stat_buf.st_mode);
531 const KDirWatch::WatchModes flag =
533 Q_FOREACH(
Client *client, this->m_clients) {
553 Q_FOREACH(
Client *client, this->m_clients) {
565 debug <<
", non-existent";
571#ifdef HAVE_SYS_INOTIFY_H
573 debug <<
" inotify_wd=" <<
entry.wd;
578 debug <<
", nonexistent subentries:";
580 debug << subEntry << subEntry->
path;
589 if (_path.isEmpty() || QDir::isRelativePath(_path)) {
595 if ( path.length() > 1 && path.endsWith( QLatin1Char(
'/' ) ) )
596 path.truncate( path.length() - 1 );
614 kDebug(7001) <<
"Global Poll Freq is now" <<
freq <<
"msec";
621bool KDirWatchPrivate::useFAM(Entry* e)
623 if (!use_fam)
return false;
635 addEntry(0, e->parentDirectory(), e,
true);
638 int res =FAMMonitorDirectory(&fc, QFile::encodeName(e->path),
646 kDebug(7001).nospace() <<
" Setup FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr))
647 <<
") for " << e->path;
653 addEntry(0, QFileInfo(e->path).absolutePath(), e,
true);
656 int res = FAMMonitorFile(&fc, QFile::encodeName(e->path),
665 kDebug(7001).nospace() <<
" Setup FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr))
666 <<
") for " << e->path;
678#ifdef HAVE_SYS_INOTIFY_H
680bool KDirWatchPrivate::useINotify( Entry* e )
687 if (!supports_inotify)
return false;
692 addEntry(0, e->parentDirectory(), e,
true);
697 int mask = IN_DELETE|IN_DELETE_SELF|IN_CREATE|IN_MOVE|IN_MOVE_SELF|IN_DONT_FOLLOW|IN_MOVED_FROM|IN_MODIFY|IN_ATTRIB;
699 if ( ( e->wd = inotify_add_watch( m_inotify_fd,
700 QFile::encodeName( e->path ),
mask) ) >= 0)
703 kDebug(7001) <<
"inotify successfully used for monitoring" << e->path <<
"wd=" << e->wd;
708 kDebug(7001) <<
"inotify failed for monitoring" << e->path <<
":" << strerror(errno);
712#ifdef HAVE_QFILESYSTEMWATCHER
723 kDebug(7001) <<
"fsWatcher->addPath" << e->
path;
748 kDebug(7001) <<
" Started Polling Timer, freq " <<
freq;
752 kDebug(7001) <<
" Setup Stat (freq " << e->
freq <<
") for " << e->
path;
764 Entry* sub_entry,
bool isDir, KDirWatch::WatchModes watchModes)
769 || path == QLatin1String(
"/dev")
770 || (path.startsWith(QLatin1String(
"/dev/")) && !path.startsWith(QLatin1String(
"/dev/."))
771 && !path.startsWith(QLatin1String(
"/dev/shm")))
776 if ( path.length() > 1 && path.endsWith( QLatin1Char(
'/' ) ) )
777 path.truncate( path.length() - 1 );
783 (*it).m_entries.append(sub_entry);
785 kDebug(7001) <<
"Added already watched Entry" << path
786 <<
"(for" << sub_entry->
path <<
")";
788#ifdef HAVE_SYS_INOTIFY_H
791 int mask = IN_DELETE|IN_DELETE_SELF|IN_CREATE|IN_MOVE|IN_MOVE_SELF|IN_DONT_FOLLOW;
793 mask |= IN_MODIFY|IN_ATTRIB;
797 inotify_rm_watch (m_inotify_fd, e->wd);
798 e->wd = inotify_add_watch( m_inotify_fd, QFile::encodeName( e->
path ),
805 (*it).addClient(instance, watchModes);
807 kDebug(7001) <<
"Added already watched Entry" << path
808 <<
"(now" << (*it).clientCount() <<
"clients)"
809 << QString::fromLatin1(
"[%1]").arg(instance->objectName());
817 KDE_struct_stat stat_buf;
818 bool exists = (
KDE::stat(path, &stat_buf) == 0);
822 Entry* e = &(*newIt);
825 e->
isDir = S_ISDIR(stat_buf.st_mode);
827 if (e->
isDir && !isDir) {
829 if (S_ISLNK(stat_buf.st_mode))
833 qWarning() <<
"KDirWatch:" << path <<
"is a directory. Use addDir!";
835 }
else if (!e->
isDir && isDir)
836 qWarning(
"KDirWatch: %s is a file. Use addFile!", qPrintable(path));
839 qWarning() <<
"KDirWatch:" << path <<
"is a file. You can't use recursive or "
840 "watchFiles options";
846 e->
m_ctime = stat_buf.st_mtime;
848 e->
m_ctime = stat_buf.st_ctime;
851 e->
m_nlink = stat_buf.st_nlink;
852 e->
m_ino = stat_buf.st_ino;
868 kDebug(7001).nospace() <<
"Added " << (e->
isDir ?
"Dir " :
"File ") << path
870 <<
" for " << (sub_entry ? sub_entry->
path :
QString())
871 <<
" [" << (instance ? instance->objectName() :
QString()) <<
"]";
881 QFlags<QDir::Filter> filters = QDir::NoDotAndDotDot;
885 filters |= (QDir::Dirs|QDir::Files);
887 filters |= QDir::Dirs;
889 filters |= QDir::Files;
892#if defined(HAVE_SYS_INOTIFY_H)
899 filters &= ~QDir::Files;
903 QDir basedir (e->
path);
904 const QFileInfoList contents = basedir.entryInfoList(filters);
905 for (QFileInfoList::const_iterator iter = contents.constBegin();
906 iter != contents.constEnd(); ++iter)
908 const QFileInfo &fileInfo = *iter;
910 bool isDir = fileInfo.isDir() && !fileInfo.isSymLink();
912 addEntry (instance, fileInfo.absoluteFilePath(), 0, isDir,
938 bool entryAdded =
false;
939 switch (preferredMethod) {
943#if defined(HAVE_SYS_INOTIFY_H)
946#if defined(HAVE_QFILESYSTEMWATCHER)
955#if defined(HAVE_SYS_INOTIFY_H)
956 if (useINotify(e))
return;
959 if (useFAM(e))
return;
961#if defined(HAVE_QFILESYSTEMWATCHER)
972 FAMCancelMonitor(&fc, &(e->fr) );
973 kDebug(7001).nospace() <<
"Cancelled FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr))
974 <<
") for " << e->
path;
977#ifdef HAVE_SYS_INOTIFY_H
979 (void) inotify_rm_watch( m_inotify_fd, e->wd );
981 kDebug(7001).nospace() <<
"Cancelled INotify (fd " << m_inotify_fd <<
", "
982 << e->wd <<
") for " << e->
path;
986#ifdef HAVE_QFILESYSTEMWATCHER
989 kDebug(7001) <<
"fsWatcher->removePath" << e->
path;
1000 kDebug(7001) <<
"path=" << _path <<
"sub_entry:" << sub_entry;
1045 kDebug(7001) <<
" Stopped Polling Timer";
1050 kDebug(7001).nospace() <<
"Removed " << (e->
isDir ?
"Dir ":
"File ") << e->
path
1051 <<
" for " << (sub_entry ? sub_entry->
path :
QString())
1052 <<
" [" << (instance ? instance->objectName() :
QString()) <<
"]";
1063 int minfreq = 3600000;
1070 foreach(
Client* client, (*it).m_clients) {
1071 if (client->
instance == instance) {
1078 pathList.append((*it).path);
1080 else if ( (*it).m_mode ==
StatMode && (*it).freq < minfreq )
1081 minfreq = (*it).freq;
1084 foreach(
const QString &path, pathList)
1087 if (minfreq >
freq) {
1091 kDebug(7001) <<
"Poll Freq now" <<
freq <<
"msec";
1098 int stillWatching = 0;
1100 if (!instance || instance == client->
instance)
1103 stillWatching += client->
count;
1106 kDebug(7001) << (instance ? instance->objectName() : QString::fromLatin1(
"all"))
1107 <<
"stopped scanning" << e->
path <<
"(now"
1108 << stillWatching <<
"watchers)";
1110 if (stillWatching == 0) {
1125 int wasWatching = 0, newWatching = 0;
1128 wasWatching += client->
count;
1129 else if (!instance || instance == client->
instance) {
1131 newWatching += client->
count;
1134 if (newWatching == 0)
1137 kDebug(7001) << (instance ? instance->objectName() : QString::fromLatin1(
"all"))
1138 <<
"restarted scanning" << e->
path
1139 <<
"(now" << wasWatching+newWatching <<
"watchers)";
1144 if (wasWatching == 0) {
1146 KDE_struct_stat stat_buf;
1151 e->
m_ctime = stat_buf.st_mtime;
1153 e->
m_ctime = stat_buf.st_ctime;
1157 kDebug(7001) <<
"Setting status to Normal for" << e << e->
path;
1159 e->
m_nlink = stat_buf.st_nlink;
1160 e->
m_ino = stat_buf.st_ino;
1170 kDebug(7001) <<
"Setting status to NonExistent for" << e << e->
path;
1192 bool notify,
bool skippedToo )
1211 foreach(
Client* client, (*it).m_clients) {
1241 KDE_struct_stat stat_buf;
1248 e->
m_ctime = qMax(stat_buf.st_ctime, stat_buf.st_mtime);
1250 e->
m_ino = stat_buf.st_ino;
1252 kDebug(7001) <<
"Setting status to Normal for just created" << e << e->
path;
1262 struct tm* tmp = localtime(&e->
m_ctime);
1264 strftime(outstr,
sizeof(outstr),
"%T", tmp);
1266 <<
"stat_buf.st_ctime=" << stat_buf.st_ctime
1267 <<
"e->m_nlink=" << e->
m_nlink
1268 <<
"stat_buf.st_nlink=" << stat_buf.st_nlink
1269 <<
"e->m_ino=" << e->
m_ino
1270 <<
"stat_buf.st_ino=" << stat_buf.st_ino;
1275 (qMax(stat_buf.st_ctime, stat_buf.st_mtime) != e->
m_ctime ||
1276 stat_buf.st_ino != e->
m_ino ||
1277 stat_buf.st_nlink != nlink_t(e->
m_nlink)))
1283 e->
m_ctime = qMax(stat_buf.st_ctime, stat_buf.st_mtime);
1284 e->
m_nlink = stat_buf.st_nlink;
1285 if (e->
m_ino != stat_buf.st_ino) {
1290 e->
m_ino = stat_buf.st_ino;
1318 if (!fileName.isEmpty()) {
1319 if (!QDir::isRelativePath(fileName))
1323 path += QLatin1Char(
'/') + fileName;
1324#elif defined(Q_WS_WIN)
1326 path += QDir::currentPath().left(2) + QLatin1Char(
'/') + fileName;
1356 QMetaObject::invokeMethod(c->
instance,
"setDeleted", Qt::QueuedConnection, Q_ARG(
QString, path));
1362 QMetaObject::invokeMethod(c->
instance,
"setCreated", Qt::QueuedConnection, Q_ARG(
QString, path));
1367 QMetaObject::invokeMethod(c->
instance,
"setDirty", Qt::QueuedConnection, Q_ARG(
QString, path));
1393 EntryMap::Iterator it;
1399 bool timerRunning =
timer.isActive();
1422 (*it).propagate_dirty();
1425#ifdef HAVE_SYS_INOTIFY_H
1440#ifdef HAVE_SYS_INOTIFY_H
1449 if (
entry->wd < 0) {
1450 cList.append(
entry);
1467#ifdef HAVE_SYS_INOTIFY_H
1474 pendingFileChanges.removeDuplicates();
1475 Q_FOREACH(
const QString &changedFilename, pendingFileChanges) {
1477 kDebug(7001) <<
"processing pending file change for" << changedFilename;
1481 entry->m_pendingFileChanges.clear();
1493#ifdef HAVE_SYS_INOTIFY_H
1495 Q_FOREACH(
Entry* e, cList)
1505 if ( *filename ==
'.') {
1506 if (strncmp(filename,
".X.err", 6) == 0)
return true;
1507 if (strncmp(filename,
".xsession-errors", 16) == 0)
return true;
1510 if (strncmp(filename,
".fonts.cache", 12) == 0)
return true;
1525 while(use_fam && FAMPending(&fc)) {
1526 if (FAMNextEvent(&fc, &fe) == -1) {
1527 kWarning(7001) <<
"FAM connection problem, switching to polling.";
1534 if ((*it).m_mode ==
FAMMode && (*it).m_clients.count()>0) {
1546void KDirWatchPrivate::checkFAMEvent(FAMEvent* fe)
1551 if ((fe->code == FAMExists) ||
1552 (fe->code == FAMEndExist) ||
1553 (fe->code == FAMAcknowledge))
return;
1561 if (FAMREQUEST_GETREQNUM(&( (*it).fr )) ==
1562 FAMREQUEST_GETREQNUM(&(fe->fr)) ) {
1570 kDebug(7001) <<
"Processing FAM event ("
1571 << ((fe->code == FAMChanged) ?
"FAMChanged" :
1572 (fe->code == FAMDeleted) ?
"FAMDeleted" :
1573 (fe->code == FAMStartExecuting) ?
"FAMStartExecuting" :
1574 (fe->code == FAMStopExecuting) ?
"FAMStopExecuting" :
1575 (fe->code == FAMCreated) ?
"FAMCreated" :
1576 (fe->code == FAMMoved) ?
"FAMMoved" :
1577 (fe->code == FAMAcknowledge) ?
"FAMAcknowledge" :
1578 (fe->code == FAMExists) ?
"FAMExists" :
1579 (fe->code == FAMEndExist) ?
"FAMEndExist" :
"Unknown Code")
1580 <<
", " << fe->filename
1581 <<
", Req " << FAMREQUEST_GETREQNUM(&(fe->fr)) <<
") e=" << e;
1591 kDebug(7001) <<
"FAM event for nonExistent entry " << e->path;
1604 if (!QDir::isRelativePath(QFile::decodeName(fe->filename))) {
1605 FAMCancelMonitor(&fc, &(e->fr) );
1606 kDebug(7001) <<
"Cancelled FAMReq"
1607 << FAMREQUEST_GETREQNUM(&(e->fr))
1608 <<
"for" << e->path;
1613 Entry* parentEntry =
entry(e->parentDirectory());
1615 parentEntry->dirty =
true;
1617 addEntry(0, e->parentDirectory(), e,
true );
1628 QString tpath(e->path + QLatin1Char(
'/') + QFile::decodeName(fe->filename));
1631 Entry* sub_entry = e->findSubEntry(tpath);
1635 sub_entry->dirty =
true;
1637 }
else if (e->isDir && !e->m_clients.empty()) {
1639 const QList<Client *> clients = e->clientsForFileOrDir(tpath, &isDir);
1640 Q_FOREACH(Client *client, clients) {
1641 addEntry (client->instance, tpath, 0, isDir,
1645 if (!clients.isEmpty()) {
1648 kDebug(7001).nospace() << clients.count() <<
" instance(s) monitoring the new "
1649 << (isDir ?
"dir " :
"file ") << tpath;
1661 kWarning (7001) <<
"Fam event received but FAM is not supported";
1668 EntryMap::Iterator it;
1670 kDebug(7001) <<
"Entries watched:";
1672 kDebug(7001) <<
" None.";
1678 kDebug(7001) <<
" " << *e;
1686 if (!pending.isEmpty()) pending =
" (pending: " + pending +
')';
1687 pending =
", stopped" + pending;
1690 <<
" (" << c->
count <<
" times)" << pending;
1693 kDebug(7001) <<
" dependent entries:";
1705#ifdef HAVE_QFILESYSTEMWATCHER
1717 kDebug(7001) <<
"scanEntry for" << e->
path <<
"says" << ev;
1724 addEntry(0, QFileInfo(e->
path).absolutePath(), e,
true);
1728 }
else if (e->
isDir) {
1740 kWarning (7001) <<
"QFileSystemWatcher event received but QFileSystemWatcher is not supported";
1751 return s_pKDirWatchSelf;
1757 return s_pKDirWatchSelf.exists();
1762 s_pKDirWatchSelf->deleteQFSWatcher();
1768 static int nameCounter = 0;
1771 setObjectName(QString::fromLatin1(
"KDirWatch-%1").arg(nameCounter) );
1777 static bool cleanupRegistered =
false;
1778 if (!cleanupRegistered) {
1779 cleanupRegistered =
true;
1798 if (d) d->
addEntry(
this, _path, 0,
true, watchModes);
1806 d->
addEntry(
this, _path, 0,
false);
1816 return QDateTime::fromTime_t(e->
m_ctime);
1823 kWarning() <<
"doesn't know" << _path;
1832 kWarning() <<
"doesn't know" << _path;
1902 kDebug(7001) <<
"KDirWatch not used";
1911 kDebug(7001) << objectName() <<
"emitting created" << _file;
1918 emit
dirty( _file );
1923 kDebug(7001) << objectName() <<
"emitting deleted" << _file;
1933#include "kdirwatch.moc"
1934#include "kdirwatch_p.moc"
A class for one specific group in a KConfig object.
void removeClient(KDirWatch *)
void addClient(KDirWatch *, KDirWatch::WatchModes)
QString parentDirectory() const
QList< Client * > m_clients
QList< Entry * > m_entries
QList< Client * > clientsForFileOrDir(const QString &tpath, bool *isDir) const
QList< Client * > inotifyClientsForFileOrDir(bool isDir) const
Entry * findSubEntry(const QString &path) const
void removeEntries(KDirWatch *)
void emitEvent(const Entry *e, int event, const QString &fileName=QString())
void useFreq(Entry *e, int newFreq)
bool restartEntryScan(KDirWatch *, Entry *, bool)
KDirWatch::Method m_nfsPreferredMethod
void removeWatch(Entry *entry)
void addEntry(KDirWatch *instance, const QString &_path, Entry *sub_entry, bool isDir, KDirWatch::WatchModes watchModes=KDirWatch::WatchDirOnly)
void addWatch(Entry *entry)
static bool isNoisyFile(const char *filename)
void stopScan(KDirWatch *)
bool removeEntry(KDirWatch *, const QString &, Entry *sub_entry)
Entry * entry(const QString &)
QSet< Entry * > removeList
void inotifyEventReceived()
KDirWatch::Method m_preferredMethod
bool useQFSWatch(Entry *e)
void fswEventReceived(const QString &path)
KFileSystemWatcher * fsWatcher
void startScan(KDirWatch *, bool, bool)
bool stopEntryScan(KDirWatch *, Entry *)
void resetList(KDirWatch *, bool)
Class for watching directory and file changes.
void setDeleted(const QString &path)
Emits deleted().
void addFile(const QString &file)
Adds a file to be watched.
void setCreated(const QString &path)
Emits created().
void stopScan()
Stops scanning of all directories in internal list.
void removeFile(const QString &file)
Removes a file from the list of watched files.
bool contains(const QString &path) const
Check if a directory is being watched by this KDirWatch instance.
bool stopDirScan(const QString &path)
Stops scanning the specified path.
static void statistics()
Dump statistic information about the KDirWatch::self() instance.
void removeDir(const QString &path)
Removes a directory from the list of scanned directories.
Method internalMethod()
Returns the preferred internal method to watch for changes.
void deleted(const QString &path)
Emitted when a file or directory is deleted.
void startScan(bool notify=false, bool skippedToo=false)
Starts scanning of all dirs in list.
static bool exists()
Returns true if there is an instance of KDirWatch.
void addDir(const QString &path, WatchModes watchModes=WatchDirOnly)
Adds a directory to be watched.
@ WatchSubDirs
Watch also all the subdirs contained by the directory.
@ WatchDirOnly
Watch just the specified directory.
@ WatchFiles
Watch also all files contained by the directory.
KDirWatch(QObject *parent=0)
Constructor.
bool isStopped()
Is scanning stopped? After creation of a KDirWatch instance, this is false.
void dirty(const QString &path)
Emitted when a watched object is changed.
void setDirty(const QString &path)
Emits dirty().
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.
bool restartDirScan(const QString &path)
Restarts scanning for specified path.
void removePath(const QString &file)
void addPath(const QString &file)
#define K_GLOBAL_STATIC(TYPE, NAME)
This macro makes it easy to use non-POD types as global statics.
static KDirWatch::Method methodFromString(const QString &method)
static const char * methodToString(KDirWatch::Method method)
static KDirWatchPrivate * dwp_self
static KDirWatchPrivate * createPrivate()
static void cleanupQFSWatcher()
static const bool s_verboseDebug
QDebug operator<<(QDebug debug, const KDirWatchPrivate::Entry &entry)
int lstat(const QString &path, KDE_struct_stat *buf)
int stat(const QString &path, KDE_struct_stat *buf)
Type fileSystemType(const QString &path)
KSharedConfigPtr config()
Returns the general config object.
KDirWatch::WatchModes m_watchModes