diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2012-10-12 11:09:25 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2012-10-12 11:09:25 -0400 |
commit | 543b7ee9f7eb104497e971961fc0c39ed32ef54d (patch) | |
tree | e20e152fa434c2d888cd1b6b256a9356618ec268 /indra/llvfs | |
parent | 6ca37068080e3b26e5cb163dfd874bc0e2f4c837 (diff) |
Fix LLUI::locateSkin() failure case; clarify lldir.cpp static init.
Per code review:
Previous refactoring of LLUI::locateSkin() preserved odd failure behavior: it
would return last-considered pathname, whether or not it exists. Changed to
emit LL_WARNS log message and return empty string.
Use Boost.Assign to simplify initialization of a couple static containers in
lldir.cpp.
Diffstat (limited to 'indra/llvfs')
-rw-r--r-- | indra/llvfs/lldir.cpp | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index 2d0adf14e6..4c0978b39e 100644 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -45,8 +45,12 @@ #include <boost/foreach.hpp> #include <boost/range/begin.hpp> #include <boost/range/end.hpp> +#include <boost/assign/list_of.hpp> #include <algorithm> +using boost::assign::list_of; +using boost::assign::map_list_of; + #if LL_WINDOWS #include "lldir_win32.h" LLDir_Win32 gDirUtil; @@ -342,37 +346,35 @@ const std::string &LLDir::getLLPluginDir() const static std::string ELLPathToString(ELLPath location) { - typedef std::map<ELLPath, const char*> ELLPathMap; -#define ENT(symbol) ELLPathMap::value_type(symbol, #symbol) - static ELLPathMap::value_type init[] = - { - ENT(LL_PATH_NONE), - ENT(LL_PATH_USER_SETTINGS), - ENT(LL_PATH_APP_SETTINGS), - ENT(LL_PATH_PER_SL_ACCOUNT), // returns/expands to blank string if we don't know the account name yet - ENT(LL_PATH_CACHE), - ENT(LL_PATH_CHARACTER), - ENT(LL_PATH_HELP), - ENT(LL_PATH_LOGS), - ENT(LL_PATH_TEMP), - ENT(LL_PATH_SKINS), - ENT(LL_PATH_TOP_SKIN), - ENT(LL_PATH_CHAT_LOGS), - ENT(LL_PATH_PER_ACCOUNT_CHAT_LOGS), - ENT(LL_PATH_USER_SKIN), - ENT(LL_PATH_LOCAL_ASSETS), - ENT(LL_PATH_EXECUTABLE), - ENT(LL_PATH_DEFAULT_SKIN), - ENT(LL_PATH_FONTS), - ENT(LL_PATH_LAST) - }; + typedef std::map<ELLPath, const char*> ELLPathMap; +#define ENT(symbol) (symbol, #symbol) + static const ELLPathMap sMap = map_list_of + ENT(LL_PATH_NONE) + ENT(LL_PATH_USER_SETTINGS) + ENT(LL_PATH_APP_SETTINGS) + ENT(LL_PATH_PER_SL_ACCOUNT) // returns/expands to blank string if we don't know the account name yet + ENT(LL_PATH_CACHE) + ENT(LL_PATH_CHARACTER) + ENT(LL_PATH_HELP) + ENT(LL_PATH_LOGS) + ENT(LL_PATH_TEMP) + ENT(LL_PATH_SKINS) + ENT(LL_PATH_TOP_SKIN) + ENT(LL_PATH_CHAT_LOGS) + ENT(LL_PATH_PER_ACCOUNT_CHAT_LOGS) + ENT(LL_PATH_USER_SKIN) + ENT(LL_PATH_LOCAL_ASSETS) + ENT(LL_PATH_EXECUTABLE) + ENT(LL_PATH_DEFAULT_SKIN) + ENT(LL_PATH_FONTS) + ENT(LL_PATH_LAST) + ; #undef ENT - static const ELLPathMap sMap(boost::begin(init), boost::end(init)); - ELLPathMap::const_iterator found = sMap.find(location); - if (found != sMap.end()) - return found->second; - return STRINGIZE("Invalid ELLPath value " << location); + ELLPathMap::const_iterator found = sMap.find(location); + if (found != sMap.end()) + return found->second; + return STRINGIZE("Invalid ELLPath value " << location); } std::string LLDir::getExpandedFilename(ELLPath location, const std::string& filename) const @@ -572,13 +574,10 @@ std::vector<std::string> LLDir::findSkinnedFilenames(const std::string& subdir, ESkinConstraint constraint) const { // Recognize subdirs that have no localization. - static const char* sUnlocalizedData[] = - { - "", // top-level directory not localized - "textures" // textures not localized - }; - static const std::set<std::string> sUnlocalized(boost::begin(sUnlocalizedData), - boost::end(sUnlocalizedData)); + static const std::set<std::string> sUnlocalized = list_of + ("") // top-level directory not localized + ("textures") // textures not localized + ; LL_DEBUGS("LLDir") << "subdir '" << subdir << "', filename '" << filename << "', constraint " |