-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.h
More file actions
38 lines (31 loc) · 794 Bytes
/
Copy pathmisc.h
File metadata and controls
38 lines (31 loc) · 794 Bytes
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
#ifndef __MISCELLANEOUS_H__
#define __MISCELLANEOUS_H__
#include <cstdlib>
#include <sstream>
// read arguments from the command line
// no bound check!
template <int N = 1>
void readargs(char** args, std::string& var) {
var = args[N];
}
template <int N = 1, typename T>
void readargs(char** args, T& var) {
std::stringstream ss(args[N]);
ss >> var;
}
template <int N = 1, typename T, typename ...Ts>
void readargs(char** args, T& var, Ts& ...rest) {
readargs<N>(args, var);
readargs<N+1>(args, rest...);
}
// mkdir
inline int mkdir(std::string const& dir) {
std::string command = "mkdir -p " + dir;
return std::system(command.c_str());
}
// touch
inline int touch(std::string const& file) {
std::string command = "touch " + file;
return std::system(command.c_str());
}
#endif