2016-09-18 20:50:08 -07:00
|
|
|
#pragma once
|
|
|
|
|
2017-03-10 15:43:54 -08:00
|
|
|
#include <Windows.h>
|
2016-09-18 20:50:08 -07:00
|
|
|
#include "vcpkg_Strings.h"
|
2016-11-29 18:08:53 -08:00
|
|
|
#include "filesystem_fs.h"
|
2017-02-14 15:35:34 -08:00
|
|
|
#include "vcpkg_optional.h"
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-01-05 12:47:08 -08:00
|
|
|
namespace vcpkg::System
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2016-11-29 18:08:53 -08:00
|
|
|
fs::path get_exe_path_of_current_process();
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-03 16:30:11 -07:00
|
|
|
struct ExitCodeAndOutput
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
|
|
|
int exit_code;
|
|
|
|
std::string output;
|
|
|
|
};
|
|
|
|
|
2017-04-03 14:21:51 -07:00
|
|
|
int cmd_execute_clean(const CWStringView cmd_line);
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-03 14:21:51 -07:00
|
|
|
int cmd_execute(const CWStringView cmd_line);
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-03 16:30:11 -07:00
|
|
|
ExitCodeAndOutput cmd_execute_and_capture_output(const CWStringView cmd_line);
|
2017-03-06 16:16:56 -08:00
|
|
|
|
2017-04-03 14:21:51 -07:00
|
|
|
std::wstring create_powershell_script_cmd(const fs::path& script_path, const CWStringView args = L"");
|
2017-03-06 16:16:56 -08:00
|
|
|
|
2017-04-03 16:31:00 -07:00
|
|
|
enum class Color
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
|
|
|
success = 10,
|
|
|
|
error = 12,
|
|
|
|
warning = 14,
|
|
|
|
};
|
|
|
|
|
2017-04-03 14:21:51 -07:00
|
|
|
void print(const CStringView message);
|
|
|
|
void println(const CStringView message);
|
2017-04-03 16:31:00 -07:00
|
|
|
void print(const Color c, const CStringView message);
|
|
|
|
void println(const Color c, const CStringView message);
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-03-28 12:33:25 -07:00
|
|
|
template <class Arg1, class...Args>
|
2017-03-28 12:51:35 -07:00
|
|
|
void print(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-03-28 12:54:18 -07:00
|
|
|
return print(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-03-28 12:33:25 -07:00
|
|
|
template <class Arg1, class...Args>
|
2017-04-03 16:31:00 -07:00
|
|
|
void print(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-03-28 12:54:18 -07:00
|
|
|
return print(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-03-28 12:33:25 -07:00
|
|
|
template <class Arg1, class...Args>
|
2017-03-28 12:51:35 -07:00
|
|
|
void println(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-03-28 12:54:18 -07:00
|
|
|
return println(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-03-28 12:33:25 -07:00
|
|
|
template <class Arg1, class...Args>
|
2017-04-03 16:31:00 -07:00
|
|
|
void println(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-03-28 12:54:18 -07:00
|
|
|
return println(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-04-03 16:27:51 -07:00
|
|
|
Optional<std::wstring> get_environmental_variable(const CWStringView varname) noexcept;
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-03 16:27:51 -07:00
|
|
|
Optional<std::wstring> get_registry_string(HKEY base, const CWStringView subkey, const CWStringView valuename);
|
2017-03-31 17:24:45 -07:00
|
|
|
|
|
|
|
const fs::path& get_ProgramFiles_32_bit();
|
|
|
|
|
|
|
|
const fs::path& get_ProgramFiles_platform_bitness();
|
2017-01-05 12:47:08 -08:00
|
|
|
}
|