From ea6292168a6acd4c263913f0ccd7dd64daf4f5cf Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Fri, 23 Feb 2018 01:45:58 +0100 Subject: Revert "Applied clang-format on source" This reverts commit 5e5c9c07291f6b09623d31c92b1fb61c4ede576e. --- src/helper.cpp | 90 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 40 deletions(-) (limited to 'src/helper.cpp') diff --git a/src/helper.cpp b/src/helper.cpp index 172cf2a2..b7fc866c 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -19,8 +19,8 @@ along with Mod Organizer. If not, see . #include "helper.h" #include "utility.h" -#include #include +#include #define WIN32_LEAN_AND_MEAN #include @@ -29,61 +29,71 @@ along with Mod Organizer. If not, see . using MOBase::reportError; + namespace Helper { -static bool helperExec(LPCWSTR moDirectory, LPCWSTR commandLine) { - wchar_t fileName[MAX_PATH]; - _snwprintf(fileName, MAX_PATH, L"%ls\\helper.exe", moDirectory); - SHELLEXECUTEINFOW execInfo = {0}; +static bool helperExec(LPCWSTR moDirectory, LPCWSTR commandLine) +{ + wchar_t fileName[MAX_PATH]; + _snwprintf(fileName, MAX_PATH, L"%ls\\helper.exe", moDirectory); + + SHELLEXECUTEINFOW execInfo = {0}; - execInfo.cbSize = sizeof(SHELLEXECUTEINFOW); - execInfo.fMask = SEE_MASK_NOCLOSEPROCESS; - execInfo.hwnd = nullptr; - execInfo.lpVerb = L"runas"; - execInfo.lpFile = fileName; - execInfo.lpParameters = commandLine; - execInfo.lpDirectory = moDirectory; - execInfo.nShow = SW_SHOW; + execInfo.cbSize = sizeof(SHELLEXECUTEINFOW); + execInfo.fMask = SEE_MASK_NOCLOSEPROCESS; + execInfo.hwnd = nullptr; + execInfo.lpVerb = L"runas"; + execInfo.lpFile = fileName; + execInfo.lpParameters = commandLine; + execInfo.lpDirectory = moDirectory; + execInfo.nShow = SW_SHOW; - ::ShellExecuteExW(&execInfo); + ::ShellExecuteExW(&execInfo); - if ((execInfo.hProcess == 0) || (::WaitForSingleObject(execInfo.hProcess, INFINITE) != WAIT_OBJECT_0)) { - reportError(QObject::tr("helper failed")); - return false; - } + if ((execInfo.hProcess == 0) || (::WaitForSingleObject(execInfo.hProcess, INFINITE) != WAIT_OBJECT_0)) { + reportError(QObject::tr("helper failed")); + return false; + } - DWORD exitCode; - GetExitCodeProcess(execInfo.hProcess, &exitCode); - return exitCode == NOERROR; + DWORD exitCode; + GetExitCodeProcess(execInfo.hProcess, &exitCode); + return exitCode == NOERROR; } -bool init(const std::wstring& moPath, const std::wstring& dataPath) { - DWORD userNameLen = UNLEN + 1; - wchar_t userName[UNLEN + 1]; - if (!GetUserName(userName, &userNameLen)) { - reportError(QObject::tr("failed to determine account name")); - return false; - } - wchar_t* commandLine = new wchar_t[32768]; +bool init(const std::wstring &moPath, const std::wstring &dataPath) +{ + DWORD userNameLen = UNLEN + 1; + wchar_t userName[UNLEN + 1]; - _snwprintf(commandLine, 32768, L"init \"%ls\" \"%ls\"", dataPath.c_str(), userName); + if (!GetUserName(userName, &userNameLen)) { + reportError(QObject::tr("failed to determine account name")); + return false; + } + wchar_t *commandLine = new wchar_t[32768]; - bool res = helperExec(moPath.c_str(), commandLine); - delete[] commandLine; + _snwprintf(commandLine, 32768, L"init \"%ls\" \"%ls\"", + dataPath.c_str(), userName); - return res; + bool res = helperExec(moPath.c_str(), commandLine); + delete [] commandLine; + + return res; } -bool backdateBSAs(const std::wstring& moPath, const std::wstring& dataPath) { - wchar_t* commandLine = new wchar_t[32768]; - _snwprintf(commandLine, 32768, L"backdateBSA \"%ls\"", dataPath.c_str()); - bool res = helperExec(moPath.c_str(), commandLine); - delete[] commandLine; +bool backdateBSAs(const std::wstring &moPath, const std::wstring &dataPath) +{ + wchar_t *commandLine = new wchar_t[32768]; + _snwprintf(commandLine, 32768, L"backdateBSA \"%ls\"", + dataPath.c_str()); + + bool res = helperExec(moPath.c_str(), commandLine); + delete [] commandLine; - return res; + return res; } -} // namespace Helper + +} // namespace -- cgit v1.3.1