forked from ouuan/BZOJ-Local-Judge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopencpp.cpp
53 lines (42 loc) · 1002 Bytes
/
opencpp.cpp
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
// opencpp <problemid>
#include <direct.h>
#include <cstdlib>
#include <fstream>
#include <string>
#include <io.h>
using namespace std;
string quote(const string & s)
{
return "\"" + s + "\"";
}
int main(int argc, char* argv[])
{
if (argc != 2)
{
puts("opencpp <problemid>");
return 1;
}
string problemid = argv[1];
string pwd = getcwd(NULL, 0);
string path = pwd + "\\problems\\" + problemid;
if (_access(path.c_str(), 0) == -1)
{
system(("mkdir " + quote(path)).c_str());
}
path += "\\" + problemid + ".cpp";
ifstream config("config.ini");
string s;
getline(config, s);
getline(config, s);
getline(config, s);
getline(config, s);
getline(config, s);
getline(config, s, ' ');
getline(config, s);
if (_access(path.c_str(), 0) == -1)
{
system(("copy " + quote(s) + " " + quote(path)).c_str());
}
system(("start \"\" " + quote(path)).c_str());
return 0;
}