diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2018-12-14 15:38:13 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2018-12-14 15:38:13 -0500 |
commit | c4096f670c7b3d43f8a5c1f65ef7e02033b0329d (patch) | |
tree | 29f3f8cae0dc5bfc983a25ec6e4e9afb245d4925 /indra/llcommon/llfile.cpp | |
parent | 132e708fec50fd756b822925313456c70a4ff27f (diff) |
SL-10153: Review and rationalize fetching paths from environment.
Use LLStringUtil::getenv() or getoptenv() whenever we fetch a string that will
be used as a pathname.
Use LLFile::tmpdir() instead of getenv("TEMP").
As an added extra-special bonus, finally clean up $TMP/llcontrol-test-zzzzzz
directories that have been accumulating every time we run a local build!
Diffstat (limited to 'indra/llcommon/llfile.cpp')
-rw-r--r-- | indra/llcommon/llfile.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index fc203f78e1..8355b1e797 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -30,6 +30,7 @@ #if LL_WINDOWS #include "llwin32headerslean.h" #include <stdlib.h> // Windows errno +#include <vector> #else #include <errno.h> #endif @@ -134,8 +135,10 @@ int warnif(const std::string& desc, const std::string& filename, int rc, int acc { // Only do any of this stuff (before LL_ENDL) if it will be logged. LL_DEBUGS("LLFile") << empty; - const char* TEMP = getenv("TEMP"); - if (! TEMP) + // would be nice to use LLDir for this, but dependency goes the + // wrong way + const char* TEMP = LLFile::tmpdir(); + if (! (TEMP && *TEMP)) { LL_CONT << "No $TEMP, not running 'handle'"; } @@ -341,17 +344,13 @@ const char *LLFile::tmpdir() #if LL_WINDOWS sep = '\\'; - DWORD len = GetTempPathW(0, L""); - llutf16string utf16path; - utf16path.resize(len + 1); - len = GetTempPathW(static_cast<DWORD>(utf16path.size()), &utf16path[0]); - utf8path = utf16str_to_utf8str(utf16path); + std::vector<wchar_t> utf16path(MAX_PATH + 1); + GetTempPathW(utf16path.size(), &utf16path[0]); + utf8path = ll_convert_wide_to_string(&utf16path[0]); #else sep = '/'; - char *env = getenv("TMPDIR"); - - utf8path = env ? env : "/tmp/"; + utf8path = LLStringUtil::getenv("TMPDIR", "/tmp/"); #endif if (utf8path[utf8path.size() - 1] != sep) { |