forked from yalewoo/CommunityDetection
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathos.h
More file actions
67 lines (51 loc) · 1.01 KB
/
os.h
File metadata and controls
67 lines (51 loc) · 1.01 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef OS_H
#define OS_H
#include <cstdlib>
#define SHOW_CMD true
struct os {
#ifdef _WIN32
static void deleteFile(const string & dir)
{
cmd("del /S/Q \"" + dir + "\"");
}
static void deleteDir(const string & dir)
{
cmd("rd /S/Q \"" + dir + "\"");
}
static void moveFile(const string & source, const string & target)
{
cmd("move /Y " + source + " " + target);
}
static void moveDir(const string & dirname, const string & target)
{
deleteDir(target + dirname);
string dir = dirname;
if (dir[dir.size() - 1] == '/')
dir[dir.size() - 1] = ' ';
moveFile(dir, "\""+target+"\"");
}
static void mkdir(const string &dir)
{
deleteFile(dir);
string dir_cmd = dir;
for (size_t i = 0; i < dir_cmd.size(); ++i)
{
if (dir_cmd[i] == '/') dir_cmd[i] = '\\';
}
cmd("mkdir " + dir_cmd);
}
static void cmd(const string s)
{
//s += " >> log.txt";
cmd(s.c_str());
}
static void cmd(const char * s)
{
if (SHOW_CMD)
printf("Call: %s\n", s);
system(s);
}
#else
#endif
};
#endif