-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleDemo.cpp
41 lines (34 loc) · 909 Bytes
/
SimpleDemo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <FileWatcher/FileWatcher.h>
#include <iostream>
/// Processes a file action
class UpdateListener : public FW::FileWatchListener
{
public:
UpdateListener() {}
void handleFileAction(FW::WatchID watchid, const FW::String& dir, const FW::String& filename,
FW::Action action)
{
std::cout << "DIR (" << dir + ") FILE (" + filename + ") has event " << action << std::endl;
}
};
int main(int argc, char **argv)
{
try
{
// create the file watcher object
FW::FileWatcher fileWatcher;
// add a watch to the system
FW::WatchID watchID = fileWatcher.addWatch("./test", new UpdateListener(), true);
std::cout << "Press ^C to exit demo" << std::endl;
// loop until a key is pressed
while(1)
{
fileWatcher.update();
}
}
catch( std::exception& e )
{
fprintf(stderr, "An exception has occurred: %s\n", e.what());
}
return 0;
}