vcpkg/toolsrc/include/vcpkg_System.h

105 lines
3.1 KiB
C
Raw Normal View History

2016-09-19 11:50:08 +08:00
#pragma once
2016-11-30 10:08:53 +08:00
#include "filesystem_fs.h"
#include "vcpkg_Strings.h"
#include "vcpkg_optional.h"
#include <Windows.h>
2016-09-19 11:50:08 +08:00
2017-01-06 04:47:08 +08:00
namespace vcpkg::System
2016-09-19 11:50:08 +08:00
{
2017-04-21 09:59:03 +08:00
tm get_current_date_time();
2016-11-30 10:08:53 +08:00
fs::path get_exe_path_of_current_process();
2016-09-19 11:50:08 +08:00
struct ExitCodeAndOutput
2016-09-19 11:50:08 +08:00
{
int exit_code;
std::string output;
};
2017-04-04 05:21:51 +08:00
int cmd_execute_clean(const CWStringView cmd_line);
2016-09-19 11:50:08 +08:00
2017-04-04 05:21:51 +08:00
int cmd_execute(const CWStringView cmd_line);
2016-09-19 11:50:08 +08:00
ExitCodeAndOutput cmd_execute_and_capture_output(const CWStringView cmd_line);
2017-04-04 05:21:51 +08:00
std::wstring create_powershell_script_cmd(const fs::path& script_path, const CWStringView args = L"");
2017-04-04 07:31:00 +08:00
enum class Color
2016-09-19 11:50:08 +08:00
{
success = 10,
error = 12,
warning = 14,
};
2017-04-04 05:21:51 +08:00
void print(const CStringView message);
void println(const CStringView message);
2017-04-04 07:31:00 +08:00
void print(const Color c, const CStringView message);
void println(const Color c, const CStringView message);
2016-09-19 11:50:08 +08:00
template<class Arg1, class... Args>
2017-03-29 03:51:35 +08:00
void print(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
{
2017-05-06 05:37:58 +08:00
return System::print(Strings::format(messageTemplate, messageArg1, messageArgs...));
}
template<class Arg1, class... Args>
2017-04-04 07:31:00 +08:00
void print(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
{
2017-05-06 05:37:58 +08:00
return System::print(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
}
template<class Arg1, class... Args>
2017-03-29 03:51:35 +08:00
void println(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
{
2017-05-06 05:37:58 +08:00
return System::println(Strings::format(messageTemplate, messageArg1, messageArgs...));
}
template<class Arg1, class... Args>
2017-04-04 07:31:00 +08:00
void println(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
{
2017-05-06 05:37:58 +08:00
return System::println(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
}
Optional<std::wstring> get_environment_variable(const CWStringView varname) noexcept;
2016-09-19 11:50:08 +08:00
2017-04-04 07:27:51 +08:00
Optional<std::wstring> get_registry_string(HKEY base, const CWStringView subkey, const CWStringView valuename);
enum class CPUArchitecture
{
X86,
X64,
ARM,
ARM64,
};
Optional<CPUArchitecture> to_cpu_architecture(CStringView arch);
CPUArchitecture get_host_processor();
const fs::path& get_ProgramFiles_32_bit();
const fs::path& get_ProgramFiles_platform_bitness();
2017-01-06 04:47:08 +08:00
}
2017-05-06 05:37:58 +08:00
namespace vcpkg::Debug
{
void println(const CStringView message);
void println(const System::Color c, const CStringView message);
template<class Arg1, class... Args>
void println(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
{
return Debug::println(Strings::format(messageTemplate, messageArg1, messageArgs...));
}
template<class Arg1, class... Args>
void println(const System::Color c,
const char* messageTemplate,
const Arg1& messageArg1,
const Args&... messageArgs)
{
return Debug::println(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
}
}