MRPT  2.0.3
test.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <mrpt/core/exceptions.h>
12 #include <cstdio>
13 #include <iostream>
14 
15 using namespace mrpt;
16 using namespace mrpt::system;
17 using namespace std;
18 
19 // ------------------------------------------------------
20 // TestWatch
21 // ------------------------------------------------------
22 void TestWatch()
23 {
25  CFileSystemWatcher::TFileSystemChangeList::iterator it;
26 
27  CFileSystemWatcher watch(".");
28 
29  printf("Watching directory '.'...\n Press any key to exit.\n");
30 
31  while (!mrpt::system::os::kbhit())
32  {
33  watch.getChanges(lstChanges);
34 
35  for (it = lstChanges.begin(); it != lstChanges.end(); it++)
36  {
37  cout << "changed: '" << it->path << "' ";
38  if (it->isDir) cout << "isDir ";
39  if (it->eventModified) cout << "modified ";
40  if (it->eventCloseWrite) cout << "close_write ";
41  if (it->eventDeleted) cout << "deleted ";
42  if (it->eventMovedTo) cout << "moved_to ";
43  if (it->eventMovedFrom) cout << "moved_from ";
44  if (it->eventCreated) cout << "created ";
45  if (it->eventAccessed) cout << "accessed";
46 
47  cout << endl;
48  }
49 
50  std::this_thread::sleep_for(100ms);
51  }
52 }
53 
54 int main()
55 {
56  try
57  {
58  TestWatch();
59  return 0;
60  }
61  catch (const std::exception& e)
62  {
63  std::cerr << "MRPT error: " << mrpt::exception_to_str(e) << std::endl;
64  return -1;
65  }
66 }
mrpt::system::os::kbhit
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
Definition: os.cpp:392
exceptions.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: BaseAppDataSource.h:15
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
mrpt::system::CFileSystemWatcher
This class subscribes to notifications of file system changes, thus it can be used to efficiently sta...
Definition: CFileSystemWatcher.h:27
CFileSystemWatcher.h
TestWatch
void TestWatch()
Definition: vision_stereo_rectify/test.cpp:22
mrpt::exception_to_str
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
Definition: exceptions.cpp:59
mrpt::system::CFileSystemWatcher::TFileSystemChangeList
std::deque< TFileSystemChange > TFileSystemChangeList
Definition: CFileSystemWatcher.h:48
mrpt::system
Definition: backtrace.h:14



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 15 15:49:54 UTC 2020