System information, environment variables, files and a timer.
System information, environment variables, files and a timer.
#include <filesystem>
#include <iostream>
int main() {
std::cout << Sys::getOSName() << " (" << Sys::getArchitecture() << "), " << Sys::getCpuName() << '\n';
std::cout << Sys::getCpuCores() << " cores, " << Sys::getAvailableRAM() / (1024 * 1024) << " MiB of RAM available\n";
std::cout << "home: " << Sys::getHomeDirectory().string() << '\n';
std::cout << "shell: " << Sys::getEnv("SHELL").value_or("unknown") << '\n';
const std::filesystem::path note = std::filesystem::temp_directory_path() / "rstools-note.txt";
std::cout << Sys::readFile(note).value_or("") << '\n';
return 0;
}
Stopwatch that can be stopped and resumed, based on a steady clock.
Definition Timer.hpp:9
static Timer startNew() noexcept
Returns a running timer.
Definition Timer.hpp:17
T getElapsedMs() const noexcept
Definition Timer.hpp:81
Portable access to system information, environment variables, files and paths.
Definition Environment.hpp:7
std::string formatNow(std::string_view format="%Y-%m-%d %H:%M:%S", TimeZone zone=TimeZone::Local)
Formats the current time; see formatTime().