-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExecInfo.cpp
More file actions
46 lines (34 loc) · 860 Bytes
/
ExecInfo.cpp
File metadata and controls
46 lines (34 loc) · 860 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
39
40
41
42
43
44
#include "ExecInfo.hpp"
#include "err.hpp"
#include <QProcess>
#include <QRegularExpression>
namespace cornus {
ExecInfo::ExecInfo() {}
ExecInfo::~ExecInfo() {}
bool ExecInfo::Run(const QString &app_path, const QString &working_dir) const
{
QRegularExpression regex("[\\s]+");
auto list = starter.split(regex);
if (list.isEmpty())
return false;
QString exe_path = list[0].trimmed();
if (exe_path.isEmpty())
return false;
QStringList args;
for (int i = 1; i < list.size(); i++) {
auto next = list[i].trimmed();
if (!next.isEmpty())
args.append(next);
}
args.append(app_path);
#ifdef CORNUS_DEBUG_EXECINFO
mtl_printq2("exe_path: ", exe_path);
for (const auto &next: args) {
mtl_printq2("arg: ", next);
}
mtl_printq2("dir_path: ", dir_path);
#endif
QProcess::startDetached(exe_path, args, working_dir);
return true;
}
}