From 481f9ba1aee62fea092184f2243d210a8686781f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Jun 2018 18:13:04 +0200 Subject: Add portable environment variable manipulation functions --- libbutl/utility.mxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libbutl/utility.mxx') diff --git a/libbutl/utility.mxx b/libbutl/utility.mxx index 740b411..252a4b4 100644 --- a/libbutl/utility.mxx +++ b/libbutl/utility.mxx @@ -35,6 +35,9 @@ export module butl.utility; import std.core; import std.io; #endif +import butl.optional; +#else +#include #endif #include @@ -183,6 +186,25 @@ LIBBUTL_MODEXPORT namespace butl bool eof (std::istream&); + // Environment variables. + // + optional + getenv (const std::string&); + + // Throw system_error on failure. + // + // Note that on Windows setting an empty value usets the variable. + // + LIBBUTL_SYMEXPORT + void + setenv (const std::string& name, const std::string& value); + + // Throw system_error on failure. + // + LIBBUTL_SYMEXPORT + void + unsetenv (const std::string&); + // Key comparators (i.e., to be used in sets, maps, etc). // struct compare_c_string -- cgit v1.1