aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/vcpkg_System.h
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2016-09-18 20:50:08 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2016-09-18 20:54:03 -0700
commitccca198c1b1730b0241911cb56dc8e3504958b2a (patch)
treea2dd9b8b087a09afdcecc5cbb3377bed15127eb2 /toolsrc/include/vcpkg_System.h
downloadvcpkg-ccca198c1b1730b0241911cb56dc8e3504958b2a.tar.gz
vcpkg-ccca198c1b1730b0241911cb56dc8e3504958b2a.zip
Initial commit
Diffstat (limited to 'toolsrc/include/vcpkg_System.h')
-rw-r--r--toolsrc/include/vcpkg_System.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h
new file mode 100644
index 000000000..f47fc9aab
--- /dev/null
+++ b/toolsrc/include/vcpkg_System.h
@@ -0,0 +1,77 @@
+#pragma once
+
+#include "vcpkg_Strings.h"
+
+#include <filesystem>
+
+namespace vcpkg {namespace System
+{
+ std::tr2::sys::path get_exe_path_of_current_process();
+
+ 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);
+ void print(color c, const char* message);
+ void println(color c, const char* message);
+
+ template <class...Args>
+ void print(const char* messageTemplate, const Args&... messageArgs)
+ {
+ return print(Strings::format(messageTemplate, messageArgs...).c_str());
+ }
+
+ template <class...Args>
+ void print(color c, const char* messageTemplate, const Args&... messageArgs)
+ {
+ 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>
+ void println(color c, const char* messageTemplate, const Args&... messageArgs)
+ {
+ return println(c, Strings::format(messageTemplate, messageArgs...).c_str());
+ }
+
+ struct Stopwatch
+ {
+ int64_t start_time, end_time, freq;
+
+ void start();
+ void stop();
+ double microseconds() const;
+ };
+
+ std::wstring wdupenv_str(const wchar_t* varname) noexcept;
+}}