diff options
Diffstat (limited to 'toolsrc/src/vcpkg_System.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg_System.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index a4e78d90a..5518e4c45 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -13,7 +13,7 @@ namespace vcpkg::System return fs::path(buf, buf + bytes); } - int cmd_execute_clean(const wchar_t* cmd_line) + int cmd_execute_clean(const cwstring_view cmd_line) { static const std::wstring system_root = *get_environmental_variable(L"SystemRoot"); static const std::wstring system_32 = system_root + LR"(\system32)"; @@ -87,7 +87,7 @@ namespace vcpkg::System return static_cast<int>(exit_code); } - int cmd_execute(const wchar_t* cmd_line) + int cmd_execute(const cwstring_view cmd_line) { // Flush stdout before launching external process _flushall(); @@ -98,7 +98,7 @@ namespace vcpkg::System return exit_code; } - exit_code_and_output cmd_execute_and_capture_output(const wchar_t* cmd_line) + exit_code_and_output cmd_execute_and_capture_output(const cwstring_view cmd_line) { // Flush stdout before launching external process fflush(stdout); @@ -124,29 +124,24 @@ namespace vcpkg::System return { ec, output }; } - std::wstring create_powershell_script_cmd(const fs::path& script_path) - { - return create_powershell_script_cmd(script_path, L""); - } - - std::wstring create_powershell_script_cmd(const fs::path& script_path, const std::wstring& args) + std::wstring create_powershell_script_cmd(const fs::path& script_path, const cwstring_view 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); } - void print(const char* message) + void print(const cstring_view message) { fputs(message, stdout); } - void println(const char* message) + void println(const cstring_view message) { print(message); putchar('\n'); } - void print(const color c, const char* message) + void print(const color c, const cstring_view message) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); @@ -159,13 +154,13 @@ namespace vcpkg::System SetConsoleTextAttribute(hConsole, original_color); } - void println(const color c, const char* message) + void println(const color c, const cstring_view message) { print(c, message); putchar('\n'); } - optional<std::wstring> get_environmental_variable(const wchar_t* varname) noexcept + optional<std::wstring> get_environmental_variable(const cwstring_view varname) noexcept { auto sz = GetEnvironmentVariableW(varname, nullptr, 0); if (sz == 0) @@ -179,7 +174,7 @@ namespace vcpkg::System return ret; } - void set_environmental_variable(const wchar_t* varname, const wchar_t* varvalue) noexcept + void set_environmental_variable(const cwstring_view varname, const cwstring_view varvalue) noexcept { _wputenv_s(varname, varvalue); } @@ -189,7 +184,7 @@ namespace vcpkg::System return hkey_type == REG_SZ || hkey_type == REG_MULTI_SZ || hkey_type == REG_EXPAND_SZ; } - optional<std::wstring> get_registry_string(HKEY base, const wchar_t* subKey, const wchar_t* valuename) + optional<std::wstring> get_registry_string(HKEY base, const cwstring_view subKey, const cwstring_view valuename) { HKEY k = nullptr; LSTATUS ec = RegOpenKeyExW(base, subKey, NULL, KEY_READ, &k); |
