File indexing completed on 2024-05-05 03:52:20

0001 /*
0002     This file is part of the KDE Baloo Project
0003     SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #include <QCoreApplication>
0009 #include <QDir>
0010 #include <QElapsedTimer>
0011 #include <iostream>
0012 
0013 #include "kinotify.h"
0014 #include "util.h"
0015 
0016 int main(int argc, char** argv)
0017 {
0018     QCoreApplication app(argc, argv);
0019 
0020     KInotify inotify(nullptr /*no config*/);
0021     QObject::connect(&inotify, &KInotify::installedWatches,
0022                      &app, &QCoreApplication::quit);
0023 
0024     QObject::connect(&inotify, &KInotify::attributeChanged,
0025                      [](const QString& fileUrl) { qDebug() << "AttrbuteChanged:" << fileUrl; });
0026     QObject::connect(&inotify, &KInotify::created,
0027                      [](const QString& fileUrl, bool isDir) { qDebug() << "Created:" << fileUrl << isDir; });
0028     QObject::connect(&inotify, &KInotify::deleted,
0029                      [](const QString& fileUrl, bool isDir) { qDebug() << "Deleted:" << fileUrl << isDir; });
0030     QObject::connect(&inotify, &KInotify::modified,
0031                      [](const QString& fileUrl) { qDebug() << "Modified:" << fileUrl; });
0032     QObject::connect(&inotify, &KInotify::closedWrite,
0033                      [](const QString& fileUrl) { qDebug() << "ClosedWrite:" << fileUrl; });
0034 
0035     QElapsedTimer timer;
0036     timer.start();
0037 
0038     KInotify::WatchEvents flags(KInotify::EventMove | KInotify::EventDelete | KInotify::EventDeleteSelf
0039                                 | KInotify::EventCloseWrite | KInotify::EventCreate
0040                                 | KInotify::EventAttributeChange | KInotify::EventModify);
0041     inotify.addWatch(QDir::homePath(), flags);
0042     app.exec();
0043 
0044     std::cout << "Elapsed: " << timer.elapsed() << std::endl;
0045     printIOUsage();
0046 }