-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor.h
53 lines (47 loc) · 1.62 KB
/
monitor.h
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
49
50
51
52
53
#include <stdlib.h>
#include <stdbool.h>
#include <limits.h>
//A part of the main config
typedef struct dirConfig{
char* dirName; //Absolute, resolved path to directory
char** whitelist; //Array of strings representing the whitelist
size_t whitelistLen;
char* move; //if NULL move is disabled
bool recursive;
bool verbose;
} dirConfig;
//Main config
typedef struct config{
dirConfig* partConfigs;
size_t len;
//Global settings
bool recursive;
bool verbose;
char* move; //Absolute resolved path to directory where to move the non compliant files, or NULL
} config;
/*!
@brief Parses the config file, and allocates necessary memory for pointers.
@param fileContents the config contents
@return a newly created config, or NULL on error
*/
config* getConfig(char* fileContents);
/*!
@brief Parses the config file
@param filename the config filename, resolved or not
@return the newly created config, or NULL on error
*/
config* getConfigFilename(const char* filename);
/*!
@brief Does a directory sweep according to the provided config
@param config the config that determines the behaviour of this sweep
@param confirm toggle for action confirm
@param recursive override for recursive behaviour
@param verbose override for logging of all actions
@param move override for move; NULL, or path to the directory where non compliant files should be moved
@return the number of affected files, or negative value in case of error
*/
int monitorDirectory(dirConfig* config, bool confirm, bool recursive, bool verbose, char* move);
/*!
@brief frees a dirConfig
*/
void freeDirConfig(dirConfig* config);