| 161 | } |
| 162 | |
| 163 | QString EngineProcess::cmdLine(const QString& wdir, |
| 164 | const QString& prog, |
| 165 | const QStringList& args) |
| 166 | { |
| 167 | bool useArgs = true; |
| 168 | QString cmd = unquote(prog); |
| 169 | |
| 170 | // Make sure we find the program |
| 171 | if (!QFile::exists(cmd) && !wdir.isEmpty()) |
| 172 | { |
| 173 | if (!wdir.endsWith('\\') && !wdir.endsWith('/')) |
| 174 | cmd.prepend('/'); |
| 175 | cmd.prepend(wdir); |
| 176 | |
| 177 | // Maybe the args are actually a part of the command |
| 178 | if (!QFile::exists(cmd) |
| 179 | && !prog.startsWith('\"') |
| 180 | && !args.isEmpty()) |
| 181 | { |
| 182 | cmd.append(" " + args.join(' ')); |
| 183 | useArgs = false; |
| 184 | } |
| 185 | |
| 186 | // Try the original command if the modified one doesn't |
| 187 | // point to an existing file. |
| 188 | if (!QFile::exists(cmd)) |
| 189 | { |
| 190 | cmd = prog; |
| 191 | useArgs = true; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | cmd = QDir::toNativeSeparators(quote(cmd)); |
| 196 | if (useArgs) |
| 197 | { |
| 198 | for (const QString& arg : args) |
| 199 | cmd += ' ' + quote(arg); |
| 200 | } |
| 201 | |
| 202 | return cmd; |
| 203 | } |
| 204 | |
| 205 | HANDLE EngineProcess::mainJob() |
| 206 | { |