summaryrefslogtreecommitdiff
path: root/zen/shell_execute.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2016-07-25 20:46:59 +0200
committerDaniel Wilhelm <daniel@wili.li>2016-07-25 20:46:59 +0200
commit37dab163d3ee934a56f7d4ef2423c973f20cd27a (patch)
tree050c0b1c35de989fa397faa34f7ed2a1df543e51 /zen/shell_execute.h
parent8.2 (diff)
downloadFreeFileSync-37dab163d3ee934a56f7d4ef2423c973f20cd27a.tar.gz
FreeFileSync-37dab163d3ee934a56f7d4ef2423c973f20cd27a.tar.bz2
FreeFileSync-37dab163d3ee934a56f7d4ef2423c973f20cd27a.zip
8.3
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