libnick 2025.9.1
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
environment.h
Go to the documentation of this file.
1
22
23#ifndef ENVIRONMENT_H
24#define ENVIRONMENT_H
25
26#if (defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS))
27#define _CRT_SECURE_NO_WARNINGS
28#endif
29
30#include <filesystem>
31#include <future>
32#include <string>
33#include <vector>
34#include "app/appinfo.h"
36#include "deploymentmode.h"
37#include "operatingsystem.h"
38
43{
49 {
50#ifdef _WIN32
52#elif defined(__linux__)
54#elif defined(__APPLE__)
56#else
58#endif
59 }
60
69 const std::filesystem::path& getExecutableDirectory() noexcept;
74 const std::filesystem::path& getExecutablePath() noexcept;
79 std::string getLocaleName() noexcept;
85 bool hasVariable(const std::string& key) noexcept;
91 std::string getVariable(const std::string& key) noexcept;
98 bool setVariable(const std::string& key, const std::string& value) noexcept;
104 bool clearVariable(const std::string& key) noexcept;
111 bool testVariable(const std::string& key) noexcept;
116 std::vector<std::filesystem::path> getPath() noexcept;
122 std::string exec(const std::string& cmd) noexcept;
128 std::future<std::string> execAsync(const std::string& cmd) noexcept;
135 const std::filesystem::path& findDependency(std::string dependency, DependencySearchOption search = DependencySearchOption::Global) noexcept;
142 std::string getDebugInformation(const App::AppInfo& appInfo, const std::string& extraInformation = "") noexcept;
143}
144
145#endif //ENVIRONMENT_H
Functions for working with the apps's shell and environment.
Definition environment.h:43
const std::filesystem::path & findDependency(std::string dependency, DependencySearchOption search=DependencySearchOption::Global) noexcept
Finds the path of a given executable dependency in the system.
bool setVariable(const std::string &key, const std::string &value) noexcept
Sets the value of an environment variable.
bool testVariable(const std::string &key) noexcept
Tests an environment variable value to see if it is true.
const std::filesystem::path & getExecutablePath() noexcept
Gets the path of the executable file.
std::string getDebugInformation(const App::AppInfo &appInfo, const std::string &extraInformation="") noexcept
Gets a debug information string about the user's environment.
std::string getLocaleName() noexcept
Gets the name of the current locale.
std::vector< std::filesystem::path > getPath() noexcept
Gets a list of directories from the system PATH variable.
bool clearVariable(const std::string &key) noexcept
Clears an environment variable.
DeploymentMode getDeploymentMode() noexcept
Gets the current deployment mode.
std::future< std::string > execAsync(const std::string &cmd) noexcept
Executes a command asynchronously in the system shell.
constexpr OperatingSystem getOperatingSystem() noexcept
Gets the current operating system.
Definition environment.h:48
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.
std::string exec(const std::string &cmd) noexcept
Executes a command in the system shell.
const std::filesystem::path & getExecutableDirectory() noexcept
Gets the path of the executable's directory.
DependencySearchOption
Search options for search for dependencies on the system.
Definition dependencysearchoption.h:32
@ Global
Definition dependencysearchoption.h:33
@ App
Definition dependencysearchoption.h:34
DeploymentMode
Supported deployment modes.
Definition deploymentmode.h:32
OperatingSystem
Supported operating systems.
Definition operatingsystem.h:32
@ MacOS
The MacOS operating system.
Definition operatingsystem.h:35
@ Other
A unknown operating system.
Definition operatingsystem.h:36
@ Windows
The Windows operating system.
Definition operatingsystem.h:33
@ Linux
The Linux operating system.
Definition operatingsystem.h:34