-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileWatcher.h
More file actions
46 lines (36 loc) · 1.02 KB
/
FileWatcher.h
File metadata and controls
46 lines (36 loc) · 1.02 KB
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
#ifndef FILEWATCHER_H
#define FILEWATCHER_H
#include <iostream>
#include <string>
#include <filesystem>
#include <vector>
#include <unordered_map>
#include <queue>
#include <unordered_set>
#include "FileStatus.h"
class Engine;
class FileWatcher {
public:
struct action {
std::string path;
FileStatus action;
};
FileWatcher(Engine* engine, std::string dirPath);
bool check();
// if there is a file delete action within a folder that will be deleted it will remove the file delete
void simplifyActions();
action getAction();
std::vector<std::string> getPaths();
void updateFileTimes(std::string);
void deleteFile(std::string);
void deleteDirectory(std::string);
private:
Engine* engine;
std::string dirToWatch;
std::queue<std::string> dirDeletes;
std::queue<action> fileChanges;
std::unordered_map<std::string, std::filesystem::file_time_type> files;
std::unordered_set<std::string> directories;
// std::vector<std::string> directories;
};
#endif