mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 02:53:10 +01:00
fixed GH #1523: Long path names under Windows
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
#include "Poco/NamedEvent.h"
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#include "Poco/Pipe.h"
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/String.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -164,7 +167,7 @@ static std::string escapeArg(const std::string& arg)
|
||||
|
||||
ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
|
||||
{
|
||||
std::string commandLine = command;
|
||||
std::string commandLine = escapeArg(command);
|
||||
for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
|
||||
{
|
||||
commandLine.append(" ");
|
||||
@@ -174,6 +177,19 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
|
||||
std::wstring ucommandLine;
|
||||
UnicodeConverter::toUTF16(commandLine, ucommandLine);
|
||||
|
||||
const wchar_t* applicationName = 0;
|
||||
std::wstring uapplicationName;
|
||||
if (command.size() > MAX_PATH)
|
||||
{
|
||||
Poco::Path p(command);
|
||||
if (p.isAbsolute())
|
||||
{
|
||||
UnicodeConverter::toUTF16(command, uapplicationName);
|
||||
if (p.getExtension().empty()) uapplicationName += L".EXE";
|
||||
applicationName = uapplicationName.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
STARTUPINFOW startupInfo;
|
||||
GetStartupInfoW(&startupInfo); // take defaults from current process
|
||||
startupInfo.cb = sizeof(STARTUPINFOW);
|
||||
@@ -253,7 +269,7 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
|
||||
PROCESS_INFORMATION processInfo;
|
||||
DWORD creationFlags = GetConsoleWindow() ? 0 : CREATE_NO_WINDOW;
|
||||
BOOL rc = CreateProcessW(
|
||||
NULL, // applicationName
|
||||
applicationName,
|
||||
const_cast<wchar_t*>(ucommandLine.c_str()),
|
||||
NULL, // processAttributes
|
||||
NULL, // threadAttributes
|
||||
|
||||
Reference in New Issue
Block a user