libnick 2024.12.0
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::System::Environment Namespace Reference

Functions

constexpr OperatingSystem getOperatingSystem ()
 Gets the current operating system.
 
DeploymentMode getDeploymentMode ()
 Gets the current deployment mode.
 
const std::filesystem::path & getExecutableDirectory ()
 Gets the path of the executable's directory.
 
std::string getLocaleName ()
 Gets the name of the current locale.
 
bool hasVariable (const std::string &key)
 Checks if an environment variable exists.
 
std::string getVariable (const std::string &key)
 Gets the value of an environment variable.
 
bool setVariable (const std::string &key, const std::string &value)
 Sets the value of an environment variable.
 
bool clearVariable (const std::string &key)
 Clears an environment variable.
 
bool testVariable (const std::string &key)
 Tests an environment variable value to see if it is true.
 
std::vector< std::filesystem::path > getPath ()
 Gets a list of directories from the system PATH variable.
 
std::string exec (const std::string &cmd)
 Executes a command in the system shell.
 
const std::filesystem::path & findDependency (std::string dependency)
 Finds the path of a given executable dependency in the system.
 
std::string getDebugInformation (const App::AppInfo &appInfo, const std::string &extraInformation="")
 Gets a debug information string about the user's environment.
 

Function Documentation

◆ clearVariable()

bool Nickvision::System::Environment::clearVariable ( const std::string & key)

Clears an environment variable.

Parameters
keyThe environment variable to delete
Returns
True if deleted, else false

◆ exec()

std::string Nickvision::System::Environment::exec ( const std::string & cmd)

Executes a command in the system shell.

Parameters
cmdThe command to execute
Returns
The output of the command

◆ findDependency()

const std::filesystem::path & Nickvision::System::Environment::findDependency ( std::string dependency)

Finds the path of a given executable dependency in the system.

The current executable's directory is searched first, then the system's PATH.

Windows UWP (Store) apps are not supported.

Parameters
dependencyThe name of the executable dependency to find
Returns
The path to the executable dependency if found, else empty path

◆ getDebugInformation()

std::string Nickvision::System::Environment::getDebugInformation ( const App::AppInfo & appInfo,
const std::string & extraInformation = "" )

Gets a debug information string about the user's environment.

appInfo The application's AppInfo

extraInformation Extra information to append to the end of the debug information string

Returns
The debug information string

◆ getDeploymentMode()

DeploymentMode Nickvision::System::Environment::getDeploymentMode ( )

Gets the current deployment mode.

Returns
The current deployment mode

◆ getExecutableDirectory()

const std::filesystem::path & Nickvision::System::Environment::getExecutableDirectory ( )

Gets the path of the executable's directory.

Returns
The executable's directory path

◆ getLocaleName()

std::string Nickvision::System::Environment::getLocaleName ( )

Gets the name of the current locale.

Returns
The locale name

◆ getOperatingSystem()

OperatingSystem Nickvision::System::Environment::getOperatingSystem ( )
constexpr

Gets the current operating system.

Returns
The current operating system

◆ getPath()

std::vector< std::filesystem::path > Nickvision::System::Environment::getPath ( )

Gets a list of directories from the system PATH variable.

Returns
The list of directories from PATH

◆ getVariable()

std::string Nickvision::System::Environment::getVariable ( const std::string & key)

Gets the value of an environment variable.

Parameters
keyThe environment variable to get
Returns
The environment variable value if found, else empty string

◆ hasVariable()

bool Nickvision::System::Environment::hasVariable ( const std::string & key)

Checks if an environment variable exists.

Parameters
keyThe environment variable to check
Returns
True if the environment variable exists, else false

◆ setVariable()

bool Nickvision::System::Environment::setVariable ( const std::string & key,
const std::string & value )

Sets the value of an environment variable.

Parameters
keyThe environment variable to set
valueThe value for the environment variable
Returns
True if set, else false

◆ testVariable()

bool Nickvision::System::Environment::testVariable ( const std::string & key)

Tests an environment variable value to see if it is true.

A true value is one that is "true", "t", "yes", "y", or "1".

Parameters
keyThe environment variable to test
Returns
True if the value is true, else false