-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand.cpp
More file actions
70 lines (57 loc) · 1.3 KB
/
Command.cpp
File metadata and controls
70 lines (57 loc) · 1.3 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
68
69
70
#include "Command.hpp"
using namespace std;
Command::Command(int nums, char* parms[]) {
vector<string> input;
for (int i = 0; i < nums; i++) {
input.push_back(parms[i]);
}
if (input.size() > 1) {
if (input[1] == "wt") {
ShellProgram = input[1];
}
else {
ShellProgram = "powershell";
}
}
else {
ShellProgram = "wt";
}
// pwd
char cwd[MAX_PATH];
ShellPwd = !_getcwd(cwd, MAX_PATH) ? "c:\\" : cwd;
if (ShellProgram == "powershell") {
if (input.size() > 2) {
ShellCommand += " Start-process " + input[1] + " -WorkingDirectory \'" + ShellPwd + "\' -ArgumentList ";
}
else {
ShellCommand += " Start-process " + input[1] + " -WorkingDirectory \'" + ShellPwd + "\' ";
}
}
else if(ShellProgram == "wt") {
ShellCommand += " -d \""+ShellPwd+"\" ";
}
bool runtag = false;
for (int i = 2; i < input.size(); i++) {
if (runtag == false) {
ShellCommand += "\"";
}
ShellCommand += input[i] + " ";
runtag = true;
}
if (runtag == true ) {
ShellCommand.pop_back();
ShellCommand += "\"";
}
};
string Command::GetProgram() {
string tmp = ShellProgram;
return tmp;
}
string Command::GetCommand() {
string tmp = ShellCommand;
return tmp;
}
string Command::GetPwd() {
string tmp = ShellPwd;
return tmp;
}