From 5e5c9c07291f6b09623d31c92b1fb61c4ede576e Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Thu, 22 Feb 2018 16:54:34 +0100 Subject: Applied clang-format on source --- src/helper.cpp | 90 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 50 deletions(-) (limited to 'src/helper.cpp') diff --git a/src/helper.cpp b/src/helper.cpp index b7fc866c..172cf2a2 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,71 +29,61 @@ 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); -static bool helperExec(LPCWSTR moDirectory, LPCWSTR commandLine) -{ - wchar_t fileName[MAX_PATH]; - _snwprintf(fileName, MAX_PATH, L"%ls\\helper.exe", moDirectory); - - SHELLEXECUTEINFOW execInfo = {0}; + 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]; -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]; - if (!GetUserName(userName, &userNameLen)) { - reportError(QObject::tr("failed to determine account name")); - return false; - } - wchar_t *commandLine = new wchar_t[32768]; + _snwprintf(commandLine, 32768, L"init \"%ls\" \"%ls\"", dataPath.c_str(), userName); - _snwprintf(commandLine, 32768, L"init \"%ls\" \"%ls\"", - dataPath.c_str(), userName); + bool res = helperExec(moPath.c_str(), commandLine); + delete[] commandLine; - bool res = helperExec(moPath.c_str(), commandLine); - delete [] commandLine; - - return res; + 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 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 res = helperExec(moPath.c_str(), commandLine); + delete[] commandLine; - return res; + return res; } - -} // namespace +} // namespace Helper -- cgit v1.3.1