summaryrefslogtreecommitdiff
path: root/zen/shell_execute.h
diff options
context:
space:
mode:
Diffstat (limited to 'zen/shell_execute.h')
-rw-r--r--zen/shell_execute.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/zen/shell_execute.h b/zen/shell_execute.h
index ce34f067..813de479 100644
--- a/zen/shell_execute.h
+++ b/zen/shell_execute.h
@@ -82,6 +82,7 @@ void shellExecute(const Zstring& command, ExecutionType type) //throw FileError
trim(commandTmp, true, false); //CommandLineToArgvW() does not like leading spaces
std::vector<Zstring> argv;
+ if (!commandTmp.empty()) //::CommandLineToArgvW returns the path to the current executable if empty string is passed
{
int argc = 0;
LPWSTR* tmp = ::CommandLineToArgvW(commandTmp.c_str(), &argc);
@@ -91,11 +92,11 @@ void shellExecute(const Zstring& command, ExecutionType type) //throw FileError
std::copy(tmp, tmp + argc, std::back_inserter(argv));
}
- Zstring filepath;
+ Zstring filePath;
Zstring arguments;
if (!argv.empty())
{
- filepath = argv[0];
+ filePath = argv[0];
for (auto it = argv.begin() + 1; it != argv.end(); ++it)
arguments += (it != argv.begin() ? L" " : L"") +
(it->empty() || std::any_of(it->begin(), it->end(), &isWhiteSpace<wchar_t>) ? L"\"" + *it + L"\"" : *it);
@@ -103,12 +104,12 @@ void shellExecute(const Zstring& command, ExecutionType type) //throw FileError
auto fillExecInfo = [&](SHELLEXECUTEINFO& execInfo)
{
- execInfo.lpFile = filepath.c_str();
+ execInfo.lpFile = filePath.c_str();
execInfo.lpParameters = arguments.c_str();
};
if (!shellExecuteImpl(fillExecInfo, type))
- THROW_LAST_FILE_ERROR(_("Incorrect command line:") + L"\nFile: " + fmtPath(filepath) + L"\nArg: " + arguments.c_str(), L"ShellExecuteEx");
+ THROW_LAST_FILE_ERROR(_("Incorrect command line:") + L"\nFile: " + fmtPath(filePath) + L"\nArg: " + arguments.c_str(), L"ShellExecuteEx");
#elif defined ZEN_LINUX || defined ZEN_MAC
/*
bgstack15