diff options
-rw-r--r-- | indra/llvfs/lldir.cpp | 40 | ||||
-rw-r--r-- | indra/llvfs/lldir.h | 4 | ||||
-rw-r--r-- | indra/llvfs/lldir_win32.cpp | 14 |
3 files changed, 45 insertions, 13 deletions
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index c2562bcfc9..ef65ab0698 100644 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -215,30 +215,44 @@ const std::string LLDir::getCacheDir(bool get_default) const { if (mCacheDir.empty() || get_default) { - std::string res; - if (getOSCacheDir().empty()) + if (!mDefaultCacheDir.empty()) + { // Set at startup - can't set here due to const API + return mDefaultCacheDir; + } + + std::string res = buildSLOSCacheDir(); + return res; + } + else + { + return mCacheDir; + } +} + +// Return the default cache directory +std::string LLDir::buildSLOSCacheDir() const +{ + std::string res; + if (getOSCacheDir().empty()) + { + if (getOSUserAppDir().empty()) { - if (getOSUserAppDir().empty()) - { - res = "data"; - } - else - { - res = getOSUserAppDir() + mDirDelimiter + "cache"; - } + res = "data"; } else { - res = getOSCacheDir() + mDirDelimiter + "SecondLife"; + res = getOSUserAppDir() + mDirDelimiter + "cache"; } - return res; } else { - return mCacheDir; + res = getOSCacheDir() + mDirDelimiter + "SecondLife"; } + return res; } + + const std::string &LLDir::getOSCacheDir() const { return mOSCacheDir; diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h index ea5186d092..e3aceee066 100644 --- a/indra/llvfs/lldir.h +++ b/indra/llvfs/lldir.h @@ -126,6 +126,9 @@ class LLDir virtual void dumpCurrentDirectories(); + // Utility routine + std::string buildSLOSCacheDir() const; + protected: std::string mAppName; // install directory under progams/ ie "SecondLife" std::string mExecutablePathAndName; // full path + Filename of .exe @@ -141,6 +144,7 @@ protected: std::string mCAFile; // Location of the TLS certificate authority PEM file. std::string mTempDir; std::string mCacheDir; // cache directory as set by user preference + std::string mDefaultCacheDir; // default cache diretory std::string mOSCacheDir; // operating system cache dir std::string mDirDelimiter; std::string mSkinDir; // Location for current skin info. diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp index ae2cd36072..bce29e4c2b 100644 --- a/indra/llvfs/lldir_win32.cpp +++ b/indra/llvfs/lldir_win32.cpp @@ -128,6 +128,20 @@ LLDir_Win32::LLDir_Win32() mAppRODataDir = getCurPath(); else mAppRODataDir = mExecutableDir; + + + // Build the default cache directory + mDefaultCacheDir = buildSLOSCacheDir(); + + // Make sure it exists + int res = LLFile::mkdir(mDefaultCacheDir); + if (res == -1) + { + if (errno != EEXIST) + { + llwarns << "Couldn't create LL_PATH_CACHE dir " << mDefaultCacheDir << llendl; + } + } } LLDir_Win32::~LLDir_Win32() |