2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vcpkg_Strings.h"
|
2016-11-30 10:08:53 +08:00
|
|
|
#include "filesystem_fs.h"
|
2017-02-15 07:35:34 +08:00
|
|
|
#include "vcpkg_optional.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
|
|
|
{
|
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 exit_code_and_output
|
|
|
|
{
|
|
|
|
int exit_code;
|
|
|
|
std::string output;
|
|
|
|
};
|
|
|
|
|
|
|
|
int cmd_execute(const wchar_t* cmd_line);
|
|
|
|
|
|
|
|
inline int cmd_execute(const std::wstring& cmd_line)
|
|
|
|
{
|
|
|
|
return cmd_execute(cmd_line.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_code_and_output cmd_execute_and_capture_output(const wchar_t* cmd_line);
|
|
|
|
|
|
|
|
inline exit_code_and_output cmd_execute_and_capture_output(const std::wstring& cmd_line)
|
|
|
|
{
|
|
|
|
return cmd_execute_and_capture_output(cmd_line.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
enum class color
|
|
|
|
{
|
|
|
|
success = 10,
|
|
|
|
error = 12,
|
|
|
|
warning = 14,
|
|
|
|
};
|
|
|
|
|
|
|
|
void print(const char* message);
|
|
|
|
void println(const char* message);
|
2016-12-13 07:08:26 +08:00
|
|
|
void print(const color c, const char* message);
|
|
|
|
void println(const color c, const char* message);
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2016-12-13 06:58:38 +08:00
|
|
|
inline void print(const std::string& message)
|
|
|
|
{
|
|
|
|
return print(message.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void println(const std::string& message)
|
|
|
|
{
|
|
|
|
return println(message.c_str());
|
|
|
|
}
|
|
|
|
|
2016-12-13 07:08:26 +08:00
|
|
|
inline void print(const color c, const std::string& message)
|
2016-12-13 06:58:38 +08:00
|
|
|
{
|
|
|
|
return print(c, message.c_str());
|
|
|
|
}
|
|
|
|
|
2016-12-13 07:08:26 +08:00
|
|
|
inline void println(const color c, const std::string& message)
|
2016-12-13 06:58:38 +08:00
|
|
|
{
|
|
|
|
return println(c, message.c_str());
|
|
|
|
}
|
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
template <class...Args>
|
|
|
|
void print(const char* messageTemplate, const Args&... messageArgs)
|
|
|
|
{
|
|
|
|
return print(Strings::format(messageTemplate, messageArgs...).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class...Args>
|
2016-12-13 07:08:26 +08:00
|
|
|
void print(const color c, const char* messageTemplate, const Args&... messageArgs)
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
|
|
|
return print(c, Strings::format(messageTemplate, messageArgs...).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class...Args>
|
|
|
|
void println(const char* messageTemplate, const Args&... messageArgs)
|
|
|
|
{
|
|
|
|
return println(Strings::format(messageTemplate, messageArgs...).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class...Args>
|
2016-12-13 07:08:26 +08:00
|
|
|
void println(const color c, const char* messageTemplate, const Args&... messageArgs)
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
|
|
|
return println(c, Strings::format(messageTemplate, messageArgs...).c_str());
|
|
|
|
}
|
|
|
|
|
2016-10-11 09:46:40 +08:00
|
|
|
struct Stopwatch2
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
|
|
|
int64_t start_time, end_time, freq;
|
|
|
|
|
|
|
|
void start();
|
|
|
|
void stop();
|
|
|
|
double microseconds() const;
|
|
|
|
};
|
|
|
|
|
2017-02-15 07:35:34 +08:00
|
|
|
optional<std::wstring> get_environmental_variable(const wchar_t* varname) noexcept;
|
2017-02-15 05:26:21 +08:00
|
|
|
|
|
|
|
void set_environmental_variable(const wchar_t* varname, const wchar_t* varvalue) noexcept;
|
2017-01-06 04:47:08 +08:00
|
|
|
}
|