You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.3 KiB
83 lines
2.3 KiB
15 years ago
|
/*
|
||
|
This file is or will be part of KDE desktop environment
|
||
|
|
||
|
Copyright 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
|
||
|
|
||
|
It is licensed under GPL version 2.
|
||
|
|
||
|
If it is part of KDE libraries than this file is licensed under
|
||
|
LGPL version 2.
|
||
|
*/
|
||
|
|
||
15 years ago
|
#include <tqfile.h>
|
||
15 years ago
|
|
||
|
#include <kdebug.h>
|
||
|
#include <kcmdlineargs.h>
|
||
|
|
||
|
#include "kdirwatchtest.h"
|
||
|
|
||
|
static const KCmdLineOptions options[] =
|
||
|
{
|
||
|
{"+[directory ...]", "Directory(ies) to watch", 0},
|
||
|
KCmdLineLastOption
|
||
|
};
|
||
|
|
||
|
|
||
|
int main (int argc, char **argv)
|
||
|
{
|
||
12 years ago
|
TDECmdLineArgs::init(argc, argv, "KDirWatchTest",
|
||
15 years ago
|
"Test for KDirWatch", "1.0");
|
||
12 years ago
|
TDECmdLineArgs::addCmdLineOptions( options );
|
||
12 years ago
|
TDEApplication::addCmdLineOptions();
|
||
15 years ago
|
|
||
12 years ago
|
TDEApplication a;
|
||
12 years ago
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
|
||
15 years ago
|
|
||
|
myTest testObject;
|
||
|
|
||
|
KDirWatch *dirwatch1 = KDirWatch::self();
|
||
|
KDirWatch *dirwatch2 = new KDirWatch;
|
||
|
|
||
15 years ago
|
testObject.connect(dirwatch1, TQT_SIGNAL( dirty( const TQString &)), TQT_SLOT( dirty( const TQString &)) );
|
||
|
testObject.connect(dirwatch1, TQT_SIGNAL( created( const TQString &)), TQT_SLOT( created( const TQString &)) );
|
||
|
testObject.connect(dirwatch1, TQT_SIGNAL( deleted( const TQString &)), TQT_SLOT( deleted( const TQString &)) );
|
||
15 years ago
|
|
||
|
if (args->count() >0) {
|
||
|
for(int i = 0; i < args->count(); i++) {
|
||
|
kdDebug() << "Watching: " << args->arg(i) << endl;
|
||
15 years ago
|
dirwatch2->addDir( TQFile::decodeName( args->arg(i)));
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString home = TQString(getenv ("HOME")) + "/";
|
||
|
TQString desk = home + "Desktop/";
|
||
15 years ago
|
kdDebug() << "Watching: " << home << endl;
|
||
|
dirwatch1->addDir(home);
|
||
|
kdDebug() << "Watching file: " << home << "foo " << endl;
|
||
|
dirwatch1->addFile(home+"foo");
|
||
|
kdDebug() << "Watching: " << desk << endl;
|
||
|
dirwatch1->addDir(desk);
|
||
15 years ago
|
TQString test = home + "test/";
|
||
15 years ago
|
kdDebug() << "Watching: (but skipped) " << test << endl;
|
||
|
dirwatch1->addDir(test);
|
||
|
|
||
|
dirwatch1->startScan();
|
||
|
dirwatch2->startScan();
|
||
|
|
||
|
if(!dirwatch1->stopDirScan(home))
|
||
|
kdDebug() << "stopDirscan: " << home << " error!" << endl;
|
||
|
if(!dirwatch1->restartDirScan(home))
|
||
|
kdDebug() << "restartDirScan: " << home << "error!" << endl;
|
||
|
if (!dirwatch1->stopDirScan(test))
|
||
|
kdDebug() << "stopDirScan: error" << endl;
|
||
|
|
||
|
KDirWatch::statistics();
|
||
|
|
||
|
delete dirwatch2;
|
||
|
|
||
|
KDirWatch::statistics();
|
||
|
|
||
|
return a.exec();
|
||
|
}
|
||
|
#include "kdirwatchtest.moc"
|