kodi
Environment.h
1 /*
2  * Copyright (C) 2013-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
16 #include <string>
17 
47 {
48 public:
60  static int setenv(const std::string &name, const std::string &value, int overwrite = 1);
67  static int unsetenv(const std::string &name);
68 
76  static int putenv(const std::string &envstring);
84  static std::string getenv(const std::string &name);
85 private:
86 #ifdef TARGET_WINDOWS
87  enum updateAction:int
88  {
89  addOrUpdateOnly = -2,
90  deleteVariable = -1,
91  addOnly = 0,
92  autoDetect = 1
93  };
94  static int win_setenv(const std::string &name, const std::string &value = "", updateAction action = autoDetect);
95  static std::string win_getenv(const std::string &name);
96 #endif // TARGET_WINDOWS
97 };
98 
Platform-independent environment variables manipulations.
Definition: Environment.h:46
static int unsetenv(const std::string &name)
Deletes environment variable.
Definition: Environment.cpp:47
static int setenv(const std::string &name, const std::string &value, int overwrite=1)
Sets or unsets environment variable.
Definition: Environment.cpp:24
static std::string getenv(const std::string &name)
Gets value of environment variable in UTF-8 encoding.
Definition: Environment.cpp:35
static int putenv(const std::string &envstring)
Adds/modifies/deletes environment variable.
Definition: Environment.cpp:56