diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:23 +0300 |
commit | 706b83ed7de5a473436620367af31fc0ceecde07 (patch) | |
tree | 103305d30dec77e8f6367753367f59b3cd68f9f1 /util/system/env.cpp | |
parent | 918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff) | |
download | ydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'util/system/env.cpp')
-rw-r--r-- | util/system/env.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/util/system/env.cpp b/util/system/env.cpp index ead9b566a5..779aa6e4fb 100644 --- a/util/system/env.cpp +++ b/util/system/env.cpp @@ -1,19 +1,19 @@ #include "env.h" -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/yexception.h> #ifdef _win_ #include <util/generic/vector.h> #include "winint.h" -#else +#else #include <cerrno> #include <cstdlib> #endif /** - * On Windows there may be many copies of enviroment variables, there at least two known, one is - * manipulated by Win32 API, another by C runtime, so we must be consistent in the choice of + * On Windows there may be many copies of enviroment variables, there at least two known, one is + * manipulated by Win32 API, another by C runtime, so we must be consistent in the choice of * functions used to manipulate them. * * Relevant links: @@ -21,35 +21,35 @@ * - https://a.yandex-team.ru/review/108892/details */ -TString GetEnv(const TString& key, const TString& def) { +TString GetEnv(const TString& key, const TString& def) { #ifdef _win_ size_t len = GetEnvironmentVariableA(key.data(), nullptr, 0); - - if (len == 0) { + + if (len == 0) { if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) { return def; } - return TString{}; - } - - TVector<char> buffer(len); - size_t bufferSize; - do { - bufferSize = buffer.size(); + return TString{}; + } + + TVector<char> buffer(len); + size_t bufferSize; + do { + bufferSize = buffer.size(); len = GetEnvironmentVariableA(key.data(), buffer.data(), static_cast<DWORD>(bufferSize)); - if (len > bufferSize) { - buffer.resize(len); - } - } while (len > bufferSize); - - return TString(buffer.data(), len); + if (len > bufferSize) { + buffer.resize(len); + } + } while (len > bufferSize); + + return TString(buffer.data(), len); #else const char* env = getenv(key.data()); - return env ? TString(env) : def; + return env ? TString(env) : def; #endif } -void SetEnv(const TString& key, const TString& value) { +void SetEnv(const TString& key, const TString& value) { bool isOk = false; int errorCode = 0; #ifdef _win_ |