TDE core libraries
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.

kdirwatchtest.cpp 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. This file is or will be part of KDE desktop environment
  3. Copyright 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
  4. It is licensed under GPL version 2.
  5. If it is part of KDE libraries than this file is licensed under
  6. LGPL version 2.
  7. */
  8. #include <tqfile.h>
  9. #include <kdebug.h>
  10. #include <tdecmdlineargs.h>
  11. #include "kdirwatchtest.h"
  12. static const TDECmdLineOptions options[] =
  13. {
  14. {"+[directory ...]", "Directory(ies) to watch", 0},
  15. TDECmdLineLastOption
  16. };
  17. int main (int argc, char **argv)
  18. {
  19. TDECmdLineArgs::init(argc, argv, "KDirWatchTest",
  20. "Test for KDirWatch", "1.0");
  21. TDECmdLineArgs::addCmdLineOptions( options );
  22. TDEApplication::addCmdLineOptions();
  23. TDEApplication a;
  24. TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
  25. myTest testObject;
  26. KDirWatch *dirwatch1 = KDirWatch::self();
  27. KDirWatch *dirwatch2 = new KDirWatch;
  28. testObject.connect(dirwatch1, TQT_SIGNAL( dirty( const TQString &)), TQT_SLOT( dirty( const TQString &)) );
  29. testObject.connect(dirwatch1, TQT_SIGNAL( created( const TQString &)), TQT_SLOT( created( const TQString &)) );
  30. testObject.connect(dirwatch1, TQT_SIGNAL( deleted( const TQString &)), TQT_SLOT( deleted( const TQString &)) );
  31. if (args->count() >0) {
  32. for(int i = 0; i < args->count(); i++) {
  33. kdDebug() << "Watching: " << args->arg(i) << endl;
  34. dirwatch2->addDir( TQFile::decodeName( args->arg(i)));
  35. }
  36. }
  37. TQString home = TQString(getenv ("HOME")) + "/";
  38. TQString desk = home + "Desktop/";
  39. kdDebug() << "Watching: " << home << endl;
  40. dirwatch1->addDir(home);
  41. kdDebug() << "Watching file: " << home << "foo " << endl;
  42. dirwatch1->addFile(home+"foo");
  43. kdDebug() << "Watching: " << desk << endl;
  44. dirwatch1->addDir(desk);
  45. TQString test = home + "test/";
  46. kdDebug() << "Watching: (but skipped) " << test << endl;
  47. dirwatch1->addDir(test);
  48. dirwatch1->startScan();
  49. dirwatch2->startScan();
  50. if(!dirwatch1->stopDirScan(home))
  51. kdDebug() << "stopDirscan: " << home << " error!" << endl;
  52. if(!dirwatch1->restartDirScan(home))
  53. kdDebug() << "restartDirScan: " << home << "error!" << endl;
  54. if (!dirwatch1->stopDirScan(test))
  55. kdDebug() << "stopDirScan: error" << endl;
  56. KDirWatch::statistics();
  57. delete dirwatch2;
  58. KDirWatch::statistics();
  59. return a.exec();
  60. }
  61. #include "kdirwatchtest.moc"