MCPcopy Create free account
hub / github.com/VioletGiraffe/file-commander / executeShellCommand

Method executeShellCommand

file-commander-core/src/shell/cshell.cpp:103–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void OsShell::executeShellCommand(const QString& command, const QString& workingDir)
104{
105 std::thread([command, workingDir] {
106 #ifdef _WIN32
107 WCHAR commandString[32768] = { 0 };
108 const auto len = (QStringLiteral("pushd ") + workingDir + " && " + command).toWCharArray(commandString);
109 //const auto len = QString{"cmd /c \"%1\""}.arg(command).toWCharArray(commandString);
110 assert_and_return_r(static_cast<size_t>(len) < std::size(commandString), );
111 ::_wsystem(commandString);
112 #else
113 const QString commandLine = "cd " % escapedPath(workingDir) % " && " % command;
114 const int result = std::system(commandLine.toUtf8().constData());
115 if (result != 0)
116 qInfo().noquote() << "The command failed with code " << result << '\n' << commandLine;
117 #endif
118 }).detach();
119}
120
121#ifdef _WIN32
122

Callers

nothing calls this directly

Calls 2

sizeFunction · 0.85
escapedPathFunction · 0.85

Tested by

no test coverage detected