MCPcopy Create free account
hub / github.com/beefytech/Beef / StartWithCreateProcess

Method StartWithCreateProcess

BeefySysLib/platform/win/Platform.cpp:1653–1852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1651 }
1652
1653 bool StartWithCreateProcess(const char* targetPath, const char* args, const char* workingDir, const char* env, BfpSpawnFlags flags, BfpSpawnResult* outResult)
1654 {
1655 String fileName = targetPath;
1656
1657 String commandLine;
1658
1659 if ((flags & BfpSpawnFlag_ArgsIncludesTarget) == 0)
1660 {
1661 if ((!fileName.StartsWith("\"")) && (!fileName.EndsWith("\"")))
1662 {
1663 bool needsQuoting = false;
1664 for (int i = 0; i < (int)fileName.length(); i++)
1665 {
1666 char c = fileName[i];
1667 if (c == ' ')
1668 needsQuoting = true;
1669 }
1670
1671 if (needsQuoting)
1672 {
1673 commandLine.Append('\"');
1674 commandLine.Append(fileName);
1675 commandLine.Append('\"');
1676 }
1677 else
1678 {
1679 commandLine.Append(fileName);
1680 }
1681 }
1682 else
1683 {
1684 commandLine.Append(fileName);
1685 }
1686 }
1687
1688 if ((args != NULL) && (args[0] != '0'))
1689 {
1690 if (!commandLine.IsEmpty())
1691 commandLine.Append(' ');
1692 commandLine.Append(args);
1693 }
1694
1695 STARTUPINFOW startupInfo = { 0 };
1696 PROCESS_INFORMATION processInfo = { 0 };
1697
1698 bool retVal;
1699 int32 errorCode = 0;
1700
1701 //
1702 {
1703 // set up the streams
1704 if ((flags & (BfpSpawnFlag_RedirectStdInput | BfpSpawnFlag_RedirectStdOutput | BfpSpawnFlag_RedirectStdError)) != 0)
1705 {
1706 if ((flags & BfpSpawnFlag_RedirectStdInput) != 0)
1707 CreatePipe(mStandardInputWritePipeHandle, startupInfo.hStdInput, true);
1708 else if (::GetConsoleWindow() != NULL)
1709 startupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
1710 else

Callers 1

Calls 8

AppendMethod · 0.80
IsHandleValidFunction · 0.70
CreatePipeFunction · 0.50
StartsWithMethod · 0.45
EndsWithMethod · 0.45
lengthMethod · 0.45
IsEmptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected