-
Notifications
You must be signed in to change notification settings - Fork 5
/
util.h
56 lines (33 loc) · 1.38 KB
/
util.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
54
55
56
#ifndef _UTIL_D9E2673EFADA464D9659570557AD587E
#define _UTIL_D9E2673EFADA464D9659570557AD587E
#include <string>
#include <functional>
namespace util
{
bool PathExists(std::string path);
bool IsRegularFile(std::string path);
bool IsDirectory(std::string path);
std::string BaseName(std::string path);
void DeleteFile(std::string path);
/* Fails if the folder is not empty */
void DeleteFolder(std::string path);
void ChangeMode(std::string path, unsigned short mode);
/* Returns the actual folder path that is created after
* appending 6 random characters to path_prefix */
std::string CreateTempFolder(std::string path_prefix);
void CreateFolder(std::string path, unsigned short mode = 0755);
/* Both source and dest must exist. Requires root */
void BindMount(std::string source, std::string dest);
void Unmount(std::string dest);
void MarkMountPointPrivate(std::string path);
void CreatePrivateMount(std::string path);
void MountSpecialFileSystem(std::string path, std::string fs);
void Chroot(std::string new_root);
void Chdir(std::string path);
using Task = std::function<void(void)>;
void ForkExecWait(char* args[], Task beforeExec);
void ForkExecWaitTimeout(char* args[], Task beforeExec, unsigned int timeout_ms);
void ForkCallWait(Task task);
void Unshare(int flags);
}
#endif