MCPcopy Create free account
hub / github.com/OpenCppCoverage/OpenCppCoverage / Start

Method Start

CppCoverage/Process.cpp:84–129  ·  view source on GitHub ↗

-------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

82
83 //-------------------------------------------------------------------------
84 void Process::Start(DWORD creationFlags)
85 {
86 if (processInformation_)
87 THROW(L"Process already started");
88
89 STARTUPINFO lpStartupInfo;
90
91 ZeroMemory(&lpStartupInfo, sizeof(lpStartupInfo));
92 const auto* workindDirectory = startInfo_.GetWorkingDirectory();
93 auto optionalCommandLine = CreateCommandLine(startInfo_.GetArguments());
94 auto commandLine = (optionalCommandLine) ? &(*optionalCommandLine)[0] : nullptr;
95
96 processInformation_ = PROCESS_INFORMATION{};
97 if (!CreateProcess(
98 nullptr,
99 commandLine,
100 nullptr,
101 nullptr,
102 FALSE,
103 creationFlags,
104 nullptr,
105 (workindDirectory) ? workindDirectory->c_str() : nullptr,
106 &lpStartupInfo,
107 &processInformation_.get()
108 ))
109 {
110 std::wostringstream ostr;
111
112 if (!Tools::FileExists(startInfo_.GetPath()))
113 ostr << CannotFindPathMessage + startInfo_.GetPath().wstring();
114 else
115 {
116 ostr
117 << CheckIfValidExecutableMessage
118 << std::endl;
119
120#ifndef _WIN64
121 ostr << L"\n*** This version support only 32 bits executable "
122 L"***.\n\n";
123#endif
124 ostr << startInfo_
125 << CppCoverage::GetErrorMessage(GetLastError());
126 }
127 throw std::runtime_error(Tools::ToLocalString(ostr.str()));
128 }
129 }
130}

Callers 2

DebugMethod · 0.80
TESTFunction · 0.80

Calls 5

CreateCommandLineFunction · 0.85
FileExistsFunction · 0.85
ToLocalStringFunction · 0.85
GetWorkingDirectoryMethod · 0.80
GetErrorMessageFunction · 0.70

Tested by 1

TESTFunction · 0.64