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

Functions for working with the apps's shell and environment. More...

Functions

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

Detailed Description

Functions for working with the apps's shell and environment.

Function Documentation

◆ clearVariable()

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

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)
noexcept

Executes a command in the system shell.

Parameters
cmdThe command to execute
Returns
The output of the command

◆ execAsync()

std::future< std::string > Nickvision::System::Environment::execAsync ( const std::string & cmd)
noexcept

Executes a command asynchronously in the system shell.

Parameters
cmdThe command to execute
Returns
The future containing the output of the command

◆ findDependency()

const std::filesystem::path & Nickvision::System::Environment::findDependency ( std::string dependency,
DependencySearchOption search = DependencySearchOption::Global )
noexcept

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

Parameters
dependencyThe name of the executable dependency to find
searchThe DependencySearchOption to use in the dependency search
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 = "" )
noexcept

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 ( )
noexcept

Gets the current deployment mode.

Returns
The current deployment mode

◆ getExecutableDirectory()

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

Gets the path of the executable's directory.

Returns
The executable's directory path

◆ getExecutablePath()

const std::filesystem::path & Nickvision::System::Environment::getExecutablePath ( )
noexcept

Gets the path of the executable file.

Returns
The executable file's path

◆ getLocaleName()

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

Gets the name of the current locale.

Returns
The locale name

◆ getOperatingSystem()

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

Gets the current operating system.

Returns
The current operating system

◆ getPath()

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

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)
noexcept

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)
noexcept

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 )
noexcept

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)
noexcept

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