diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-04-27 18:08:52 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-04-27 18:59:57 -0700 |
| commit | 1e9471a1489156720362ef12e1ec6849ea9b45b6 (patch) | |
| tree | 46f0f35093ecd18034c9f9463d6f8b7aa590ade0 /toolsrc/src/vcpkg_System.cpp | |
| parent | 75e8752cb90eb8bc7717518d9d6a5c68f27f2b0f (diff) | |
| download | vcpkg-1e9471a1489156720362ef12e1ec6849ea9b45b6.tar.gz vcpkg-1e9471a1489156720362ef12e1ec6849ea9b45b6.zip | |
Run clang-format over the cpp files
Diffstat (limited to 'toolsrc/src/vcpkg_System.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg_System.cpp | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index f5a34e3ea..7c06759af 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -1,6 +1,7 @@ #include "pch.h" -#include "vcpkg_System.h" + #include "vcpkg_Checks.h" +#include "vcpkg_System.h" #include "vcpkglib.h" namespace vcpkg::System @@ -18,19 +19,19 @@ namespace vcpkg::System { wchar_t buf[_MAX_PATH]; int bytes = GetModuleFileNameW(nullptr, buf, _MAX_PATH); - if (bytes == 0) - std::abort(); + if (bytes == 0) std::abort(); return fs::path(buf, buf + bytes); } int cmd_execute_clean(const CWStringView cmd_line) { - static const std::wstring system_root = get_environmental_variable(L"SystemRoot").value_or_exit(VCPKG_LINE_INFO); + static const std::wstring system_root = + get_environmental_variable(L"SystemRoot").value_or_exit(VCPKG_LINE_INFO); static const std::wstring system_32 = system_root + LR"(\system32)"; - static const std::wstring new_PATH = Strings::wformat(LR"(Path=%s;%s;%s\Wbem;%s\WindowsPowerShell\v1.0\)", system_32, system_root, system_32, system_32); + static const std::wstring new_PATH = Strings::wformat( + LR"(Path=%s;%s;%s\Wbem;%s\WindowsPowerShell\v1.0\)", system_32, system_root, system_32, system_32); - std::vector<std::wstring> env_wstrings = - { + std::vector<std::wstring> env_wstrings = { L"ALLUSERSPROFILE", L"APPDATA", L"CommonProgramFiles", @@ -84,8 +85,7 @@ namespace vcpkg::System { const Optional<std::wstring> value = System::get_environmental_variable(env_wstring); auto v = value.get(); - if (!v || v->empty()) - continue; + if (!v || v->empty()) continue; env_wstring.push_back(L'='); env_wstring.append(*v); @@ -97,11 +97,10 @@ namespace vcpkg::System // Basically we are wrapping it in quotes const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); - if (g_debugging) - System::println("[DEBUG] _wspawnlpe(cmd.exe /c %s)", Strings::utf16_to_utf8(actual_cmd_line)); - auto exit_code = _wspawnlpe(_P_WAIT, L"cmd.exe", L"cmd.exe", L"/c", actual_cmd_line.c_str(), nullptr, env_cstr.data()); - if (g_debugging) - System::println("[DEBUG] _wspawnlpe() returned %d", exit_code); + if (g_debugging) System::println("[DEBUG] _wspawnlpe(cmd.exe /c %s)", Strings::utf16_to_utf8(actual_cmd_line)); + auto exit_code = + _wspawnlpe(_P_WAIT, L"cmd.exe", L"cmd.exe", L"/c", actual_cmd_line.c_str(), nullptr, env_cstr.data()); + if (g_debugging) System::println("[DEBUG] _wspawnlpe() returned %d", exit_code); return static_cast<int>(exit_code); } @@ -112,11 +111,9 @@ namespace vcpkg::System // Basically we are wrapping it in quotes const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); - if (g_debugging) - System::println("[DEBUG] _wsystem(%s)", Strings::utf16_to_utf8(actual_cmd_line)); + if (g_debugging) System::println("[DEBUG] _wsystem(%s)", Strings::utf16_to_utf8(actual_cmd_line)); int exit_code = _wsystem(actual_cmd_line.c_str()); - if (g_debugging) - System::println("[DEBUG] _wsystem() returned %d", exit_code); + if (g_debugging) System::println("[DEBUG] _wsystem() returned %d", exit_code); return exit_code; } @@ -149,13 +146,11 @@ namespace vcpkg::System std::wstring create_powershell_script_cmd(const fs::path& script_path, const CWStringView args) { // TODO: switch out ExecutionPolicy Bypass with "Remove Mark Of The Web" code and restore RemoteSigned - return Strings::wformat(LR"(powershell -NoProfile -ExecutionPolicy Bypass -Command "& {& '%s' %s}")", script_path.native(), args); + return Strings::wformat( + LR"(powershell -NoProfile -ExecutionPolicy Bypass -Command "& {& '%s' %s}")", script_path.native(), args); } - void print(const CStringView message) - { - fputs(message, stdout); - } + void print(const CStringView message) { fputs(message, stdout); } void println(const CStringView message) { @@ -185,8 +180,7 @@ namespace vcpkg::System Optional<std::wstring> get_environmental_variable(const CWStringView varname) noexcept { auto sz = GetEnvironmentVariableW(varname, nullptr, 0); - if (sz == 0) - return nullopt; + if (sz == 0) return nullopt; std::wstring ret(sz, L'\0'); @@ -206,13 +200,13 @@ namespace vcpkg::System { HKEY k = nullptr; LSTATUS ec = RegOpenKeyExW(base, subKey, NULL, KEY_READ, &k); - if (ec != ERROR_SUCCESS) - return nullopt; + if (ec != ERROR_SUCCESS) return nullopt; DWORD dwBufferSize = 0; DWORD dwType = 0; auto rc = RegQueryValueExW(k, valuename, nullptr, &dwType, nullptr, &dwBufferSize); - if (rc != ERROR_SUCCESS || !is_string_keytype(dwType) || dwBufferSize == 0 || dwBufferSize % sizeof(wchar_t) != 0) + if (rc != ERROR_SUCCESS || !is_string_keytype(dwType) || dwBufferSize == 0 || + dwBufferSize % sizeof(wchar_t) != 0) return nullopt; std::wstring ret; ret.resize(dwBufferSize / sizeof(wchar_t)); @@ -233,29 +227,27 @@ namespace vcpkg::System const fs::path& get_ProgramFiles_32_bit() { - static const fs::path p = []() -> fs::path + static const fs::path p = []() -> fs::path { + auto value = System::get_environmental_variable(L"ProgramFiles(x86)"); + if (auto v = value.get()) { - auto value = System::get_environmental_variable(L"ProgramFiles(x86)"); - if (auto v = value.get()) - { - return std::move(*v); - } - return get_ProgramFiles(); - }(); + return std::move(*v); + } + return get_ProgramFiles(); + }(); return p; } const fs::path& get_ProgramFiles_platform_bitness() { - static const fs::path p = []() -> fs::path + static const fs::path p = []() -> fs::path { + auto value = System::get_environmental_variable(L"ProgramW6432"); + if (auto v = value.get()) { - auto value = System::get_environmental_variable(L"ProgramW6432"); - if (auto v = value.get()) - { - return std::move(*v); - } - return get_ProgramFiles(); - }(); + return std::move(*v); + } + return get_ProgramFiles(); + }(); return p; } } |
