Medical Imaging Interaction Toolkit  2025.08.99-f7084adb
Medical Imaging Interaction Toolkit
Environment variable utilities

Functions for querying and modifying environment variables in MITK. More...

Functions

MITKCORE_EXPORT std::optional< std::string > mitk::GetEnv (const std::string &name)
 Retrieve the value of an environment variable. More...
 
MITKCORE_EXPORT bool mitk::SetEnv (const std::string &name, const std::string &value)
 Set the value of an environment variable. More...
 
MITKCORE_EXPORT bool mitk::UnsetEnv (const std::string &name)
 Remove an environment variable. More...
 
MITKCORE_EXPORT bool mitk::AddPathEnv (const fs::path &pathEntry)
 Add a directory to the PATH environment variable. More...
 
MITKCORE_EXPORT bool mitk::RemovePathEnv (const fs::path &pathEntry)
 Remove a directory from the PATH environment variable. More...
 

Detailed Description

Functions for querying and modifying environment variables in MITK.

These functions provide a platform-independent interface for retrieving, setting, and removing environment variables, as well as manipulating the PATH variable.

Function Documentation

◆ AddPathEnv()

MITKCORE_EXPORT bool mitk::AddPathEnv ( const fs::path &  pathEntry)

Add a directory to the PATH environment variable.

The path is normalized before being added. If it already exists in PATH, no changes are made.

Parameters
pathEntryDirectory to add to PATH.
Returns
true if the path was added or already existed, false if the operation failed.

◆ GetEnv()

MITKCORE_EXPORT std::optional<std::string> mitk::GetEnv ( const std::string &  name)

Retrieve the value of an environment variable.

This function looks up the given environment variable name and returns its value if it exists.

Parameters
nameName of the environment variable.
Returns
The value of the environment variable if set, or std::nullopt if not found.

◆ RemovePathEnv()

MITKCORE_EXPORT bool mitk::RemovePathEnv ( const fs::path &  pathEntry)

Remove a directory from the PATH environment variable.

The path is normalized before comparison. If the path is not present, no changes are made.

Parameters
pathEntryDirectory to remove from PATH.
Returns
true if the path was removed or was not present, false if the operation failed.

◆ SetEnv()

MITKCORE_EXPORT bool mitk::SetEnv ( const std::string &  name,
const std::string &  value 
)

Set the value of an environment variable.

If the environment variable already exists, its value is overwritten.

Parameters
nameName of the environment variable.
valueNew value for the environment variable.
Returns
true if the variable was successfully set, false otherwise.

◆ UnsetEnv()

MITKCORE_EXPORT bool mitk::UnsetEnv ( const std::string &  name)

Remove an environment variable.

The variable is removed from the current process environment.

Parameters
nameName of the environment variable to remove.
Returns
true if the variable was successfully removed, false otherwise.