/****************************************************************************** * Copyright (c) 2017, Connor Manning (connor@hobu.co) * * Entwine -- Point cloud indexing * * Entwine is available under the terms of the LGPL2 license. See COPYING * for specific license text and more information. * ******************************************************************************/ #pragma once #include #include #include #include namespace entwine { inline std::unique_ptr env(const std::string& var) { std::unique_ptr result; #ifndef _WIN32 if (const char* c = getenv(var.c_str())) return makeUnique(c); #else char* c(nullptr); std::size_t size(0); if (!_dupenv_s(&c, &size, var.c_str())) { if (c) { auto r = makeUnique(c); free(c); return r; } } #endif return std::unique_ptr(); } } // namespace entwine