mirror of
https://github.com/arun11299/cpp-subprocess.git
synced 2025-08-04 12:26:19 -04:00
Added 'call' overload (#89)
* Added 'call' overload * Use CREATE_NO_WINDOW flag for process creation in Win32 * Change way of quoting arguments so explorer /select can be called (should find a better way to do this) --------- Co-authored-by: Santiago <san@san.san>
This commit is contained in:
parent
af23f33880
commit
5a8adeb758
@ -178,9 +178,9 @@ namespace util
|
|||||||
// need to do so --- hopefully avoid problems if programs won't
|
// need to do so --- hopefully avoid problems if programs won't
|
||||||
// parse quotes properly
|
// parse quotes properly
|
||||||
//
|
//
|
||||||
|
bool containsCharThatNeedsQuoting = argument.find_first_of(L" \t\n\v\"") != argument.npos;
|
||||||
if (force == false && argument.empty() == false &&
|
bool containsCharThatNeedsNoQuoting = argument.find_first_of(L"/") != argument.npos;
|
||||||
argument.find_first_of(L" \t\n\v\"") == argument.npos) {
|
if (!force && !argument.empty() && (!containsCharThatNeedsQuoting || containsCharThatNeedsNoQuoting)) {
|
||||||
command_line.append(argument);
|
command_line.append(argument);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1514,7 +1514,7 @@ inline void Popen::execute_process() noexcept(false)
|
|||||||
|
|
||||||
for (auto arg : this->vargs_) {
|
for (auto arg : this->vargs_) {
|
||||||
argument = converter.from_bytes(arg);
|
argument = converter.from_bytes(arg);
|
||||||
util::quote_argument(argument, command_line, true);
|
util::quote_argument(argument, command_line, false);
|
||||||
command_line += L" ";
|
command_line += L" ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1524,7 +1524,7 @@ inline void Popen::execute_process() noexcept(false)
|
|||||||
PROCESS_INFORMATION piProcInfo;
|
PROCESS_INFORMATION piProcInfo;
|
||||||
STARTUPINFOW siStartInfo;
|
STARTUPINFOW siStartInfo;
|
||||||
BOOL bSuccess = FALSE;
|
BOOL bSuccess = FALSE;
|
||||||
DWORD creation_flags = CREATE_UNICODE_ENVIRONMENT;
|
DWORD creation_flags = CREATE_UNICODE_ENVIRONMENT | CREATE_NO_WINDOW;
|
||||||
|
|
||||||
// Set up members of the PROCESS_INFORMATION structure.
|
// Set up members of the PROCESS_INFORMATION structure.
|
||||||
ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
|
ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
|
||||||
@ -2050,6 +2050,12 @@ int call(const std::string& arg, Args&&... args)
|
|||||||
return (detail::call_impl(arg, std::forward<Args>(args)...));
|
return (detail::call_impl(arg, std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
int call(std::vector<std::string> plist, Args &&... args)
|
||||||
|
{
|
||||||
|
return (detail::call_impl(plist, std::forward<Args>(args)...));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Run the command with arguments and wait for it to complete.
|
* Run the command with arguments and wait for it to complete.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user