summaryrefslogtreecommitdiff
path: root/wx+/shell_execute.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:26:50 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:26:50 +0200
commit669df123648aaa6aeccc70206b5417bc48b4e9ae (patch)
tree463c107a8d6405020bb304f7a7253e6b64afeee0 /wx+/shell_execute.h
parent5.18 (diff)
downloadFreeFileSync-669df123648aaa6aeccc70206b5417bc48b4e9ae.tar.gz
FreeFileSync-669df123648aaa6aeccc70206b5417bc48b4e9ae.tar.bz2
FreeFileSync-669df123648aaa6aeccc70206b5417bc48b4e9ae.zip
5.19
Diffstat (limited to 'wx+/shell_execute.h')
-rw-r--r--wx+/shell_execute.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/wx+/shell_execute.h b/wx+/shell_execute.h
index 8965186e..1d67aa21 100644
--- a/wx+/shell_execute.h
+++ b/wx+/shell_execute.h
@@ -42,12 +42,15 @@ void shellExecute(const Zstring& command, ExecutionType type = EXEC_TYPE_ASYNC)
{
#ifdef ZEN_WIN
//parse commandline
+ Zstring commandTmp = command;
+ trim(commandTmp, true, false); //CommandLineToArgvW() does not like leading spaces
+
std::vector<std::wstring> argv;
int argc = 0;
- if (LPWSTR* tmp = ::CommandLineToArgvW(command.c_str(), &argc))
+ if (LPWSTR* tmp = ::CommandLineToArgvW(commandTmp.c_str(), &argc))
{
+ ZEN_ON_SCOPE_EXIT(::LocalFree(tmp));
std::copy(tmp, tmp + argc, std::back_inserter(argv));
- ::LocalFree(tmp);
}
std::wstring filename;
@@ -74,7 +77,7 @@ void shellExecute(const Zstring& command, ExecutionType type = EXEC_TYPE_ASYNC)
if (!::ShellExecuteEx(&execInfo)) //__inout LPSHELLEXECUTEINFO lpExecInfo
{
wxString cmdFmt = L"File: " + filename + L"\nArg: " + arguments;
- wxMessageBox(_("Invalid command line:") + L"\n" + cmdFmt + L"\n\n" + formatSystemError(L"ShellExecuteEx", getLastError()));
+ wxMessageBox(_("Invalid command line:") + L"\n" + cmdFmt + L"\n\n" + formatSystemError(L"ShellExecuteEx", getLastError()), /*L"FreeFileSync - " + */_("Error"), wxOK | wxICON_ERROR);
return;
}
@@ -99,7 +102,7 @@ void shellExecute(const Zstring& command, ExecutionType type = EXEC_TYPE_ASYNC)
//Posix::system - execute a shell command
int rv = ::system(command.c_str()); //do NOT use std::system as its documentation says nothing about "WEXITSTATUS(rv)", ect...
if (rv == -1 || WEXITSTATUS(rv) == 127) //http://linux.die.net/man/3/system "In case /bin/sh could not be executed, the exit status will be that of a command that does exit(127)"
- wxMessageBox(_("Invalid command line:") + L"\n" + utfCvrtTo<wxString>(command));
+ wxMessageBox(_("Invalid command line:") + L"\n" + utfCvrtTo<wxString>(command), /*L"FreeFileSync - " +*/ _("Error"), wxOK | wxICON_ERROR);
}
else
async([=] { int rv = ::system(command.c_str()); (void)rv; });
bgstack15