HoverRace
2.0
|
Operating system support utilities. More...
Typedefs | |
using | cpstr_t = const path_t::value_type * |
using | dirEnt_t = boost::filesystem::directory_entry |
using | dirIter_t = boost::filesystem::directory_iterator |
using | fs_error_t = boost::filesystem::filesystem_error |
using | path_t = boost::filesystem::path |
using | pstr_t = path_t::value_type * |
using | timestamp_t = MR_Int64 |
Functions | |
std::string | FileTimeString () |
Generate a string representing the current timestamp, suitable for filenames. More... | |
OS::path_t | FindExePath () |
Find the path of the executable itself. More... | |
FILE * | FOpen (const path_t &path, const char *mode) |
Open a file using the OS-specific path format. More... | |
std::string | GetUsername () |
Get the username of the current OS user. More... | |
bool | OpenLink (const std::string &url) |
Open a URL. More... | |
bool | OpenPath (const path_t &path) |
Open a filesystem path. More... | |
void | SetEnv (const char *key, const char *val) |
Set an environment variable. More... | |
const std::locale & | SetLocale (const path_t &path, const std::string &domain, const std::string &reqLocale={}) |
Set the locale based on the current environment. More... | |
void | ShowMessage (const std::string &s, bool error=false) |
Display a simple error message to the user. More... | |
std::string | StrError (int errnum) |
Convert an error number to a string. More... | |
timestamp_t | Time () |
Retrieve a timestamp. More... | |
constexpr timestamp_t | TimeDiff (timestamp_t laterTs, timestamp_t earlierTs) noexcept |
Calculate the difference between two timestamps. More... | |
void | TimeInit () |
Initialize the OS time source. More... | |
void | TimeShutdown () |
Shutdown the OS time source. More... | |
Variables | |
std::locale | locale {""} |
Global reference to the current locale. More... | |
const std::locale & | stdLocale = std::locale::classic() |
The standard "C" locale for things that should be not be affected by locale. More... | |
Operating system support utilities.
using HoverRace::Util::OS::cpstr_t = typedef const path_t::value_type* |
using HoverRace::Util::OS::dirEnt_t = typedef boost::filesystem::directory_entry |
using HoverRace::Util::OS::dirIter_t = typedef boost::filesystem::directory_iterator |
using HoverRace::Util::OS::fs_error_t = typedef boost::filesystem::filesystem_error |
using HoverRace::Util::OS::path_t = typedef boost::filesystem::path |
using HoverRace::Util::OS::pstr_t = typedef path_t::value_type* |
using HoverRace::Util::OS::timestamp_t = typedef MR_Int64 |
std::string HoverRace::Util::OS::FileTimeString | ( | ) |
Generate a string representing the current timestamp, suitable for filenames.
OS::path_t HoverRace::Util::OS::FindExePath | ( | ) |
Find the path of the executable itself.
FILE * HoverRace::Util::OS::FOpen | ( | const path_t & | path, |
const char * | mode | ||
) |
Open a file using the OS-specific path format.
path | The file to open. |
mode | The mode (same as POSIX {fopen(3)} ). |
NULL
if an error occurred. std::string HoverRace::Util::OS::GetUsername | ( | ) |
Get the username of the current OS user.
bool HoverRace::Util::OS::OpenLink | ( | const std::string & | url | ) |
Open a URL.
url | The URL (UTF-8 encoded). |
true
if successful, false
otherwise. bool HoverRace::Util::OS::OpenPath | ( | const path_t & | path | ) |
Open a filesystem path.
Only directories may be opened; they will be opened using the native file navigator.
path | The path to open. |
true
if successful, false
otherwise. void HoverRace::Util::OS::SetEnv | ( | const char * | key, |
const char * | val | ||
) |
Set an environment variable.
key | The variable name (may not be NULL). |
val | The variable value (may not be NULL). |
Exception |
const std::locale & HoverRace::Util::OS::SetLocale | ( | const path_t & | path, |
const std::string & | domain, | ||
const std::string & | reqLocale = {} |
||
) |
Set the locale based on the current environment.
path | The path to where compiled translations can be found. |
domain | The translation domain to use. |
reqLocale | The requested locale. If blank, the system default will be used. |
void HoverRace::Util::OS::ShowMessage | ( | const std::string & | s, |
bool | error = false |
||
) |
Display a simple error message to the user.
On Windows, this will pop up a message box, elsewhere this will just output to the console.
s | The message. |
error | true to indicate this is an error message. |
std::string HoverRace::Util::OS::StrError | ( | int | errnum | ) |
Convert an error number to a string.
errnum | The error number, usually errno . |
OS::timestamp_t HoverRace::Util::OS::Time | ( | ) |
Retrieve a timestamp.
The value returned is OS-dependent and should only be used for relative calculations.
|
inlinenoexcept |
Calculate the difference between two timestamps.
This properly handles wraparound in timestamps.
laterTs | The later timestamp. |
earlierTs | The earlier timestamp. |
laterTs
- earlierTs
void HoverRace::Util::OS::TimeInit | ( | ) |
Initialize the OS time source.
void HoverRace::Util::OS::TimeShutdown | ( | ) |
Shutdown the OS time source.
std::locale HoverRace::Util::OS::locale {""} |
Global reference to the current locale.
Defaults to "C" until OS::SetLocale() is called.
const std::locale & HoverRace::Util::OS::stdLocale = std::locale::classic() |
The standard "C" locale for things that should be not be affected by locale.