MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / Detail_

Class Detail_

LuaSTGPlus/LuaWrapper.cpp:1687–1726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1685 static int Execute(lua_State* L)LNOEXCEPT
1686 {
1687 struct Detail_
1688 {
1689 LNOINLINE static bool Execute(const char* path, const char* args, const char* directory, bool bWait, bool bShow)LNOEXCEPT
1690 {
1691 wstring tPath, tArgs, tDirectory;
1692
1693 try
1694 {
1695 tPath = fcyStringHelper::MultiByteToWideChar(path, CP_UTF8);
1696 tArgs = fcyStringHelper::MultiByteToWideChar(args, CP_UTF8);
1697 if (directory)
1698 tDirectory = fcyStringHelper::MultiByteToWideChar(directory, CP_UTF8);
1699
1700 SHELLEXECUTEINFO tShellExecuteInfo;
1701 memset(&tShellExecuteInfo, 0, sizeof(SHELLEXECUTEINFO));
1702
1703 tShellExecuteInfo.cbSize = sizeof(SHELLEXECUTEINFO);
1704 tShellExecuteInfo.fMask = bWait ? SEE_MASK_NOCLOSEPROCESS : 0;
1705 tShellExecuteInfo.lpVerb = L"open";
1706 tShellExecuteInfo.lpFile = tPath.c_str();
1707 tShellExecuteInfo.lpParameters = tArgs.c_str();
1708 tShellExecuteInfo.lpDirectory = directory ? tDirectory.c_str() : nullptr;
1709 tShellExecuteInfo.nShow = bShow ? SW_SHOWDEFAULT : SW_HIDE;
1710
1711 if (FALSE == ShellExecuteEx(&tShellExecuteInfo))
1712 return false;
1713
1714 if (bWait)
1715 {
1716 WaitForSingleObject(tShellExecuteInfo.hProcess, INFINITE);
1717 CloseHandle(tShellExecuteInfo.hProcess);
1718 }
1719 return true;
1720 }
1721 catch (const std::bad_alloc&)
1722 {
1723 return false;
1724 }
1725 }
1726 };
1727
1728 const char* path = luaL_checkstring(L, 1);
1729 const char* args = luaL_optstring(L, 2, "");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected