-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
48 lines (39 loc) · 1.18 KB
/
main.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
42
43
44
45
46
47
48
#include "pfw/FileSystemWatcher.h"
#include <bitset>
#include <chrono>
#include <filesystem>
#include <memory>
class Listener
{
public:
Listener(std::filesystem::path path)
{
_watcher = std::make_unique<pfw::FileSystemWatcher>(
path, std::chrono::milliseconds(1),
std::bind(&Listener::listenerFunction, this,
std::placeholders::_1));
}
void listenerFunction(std::vector<pfw::EventPtr> events)
{
for (const auto &event : events) {
std::bitset<16> typeBits(event->type);
std::cout << event->relativePath << " with the type: " << typeBits
<< std::endl;
}
}
private:
std::unique_ptr<pfw::FileSystemWatcher> _watcher;
};
int main(int argc, char *argv[])
{
if (argc < 2) {
std::cout << "one input parameter is needed" << std::endl;
return 1;
}
const auto path = std::filesystem::path(argv[1]);
std::cout << "observed path is '" << path.string() << "'" << std::endl;
auto listenerInstance = Listener(path);
std::cout << "Press any key to finish the observation!" << std::endl;
std::cin.ignore();
return 0;
}