From 6e91a9cc3d5a610198cf526a76e2ab642f10ecd7 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:59 -0500 Subject: Second Life viewer sources 1.20.13 --- linden/indra/llvfs/lldir.cpp | 107 ++++++++++++++++++++++++++++--------- linden/indra/llvfs/lldir.h | 24 +++++++-- linden/indra/llvfs/lldir_linux.cpp | 2 +- linden/indra/llvfs/lldir_linux.h | 2 +- linden/indra/llvfs/lldir_mac.cpp | 2 +- linden/indra/llvfs/lldir_mac.h | 2 +- linden/indra/llvfs/lldir_win32.cpp | 2 +- linden/indra/llvfs/lldir_win32.h | 2 +- 8 files changed, 106 insertions(+), 37 deletions(-) (limited to 'linden/indra/llvfs') diff --git a/linden/indra/llvfs/lldir.cpp b/linden/indra/llvfs/lldir.cpp index 084d3aa..246595a 100644 --- a/linden/indra/llvfs/lldir.cpp +++ b/linden/indra/llvfs/lldir.cpp @@ -59,18 +59,8 @@ LLDir_Linux gDirUtil; LLDir *gDirUtilp = (LLDir *)&gDirUtil; -LLDir::LLDir() -: mAppName(""), - mExecutablePathAndName(""), - mExecutableFilename(""), - mExecutableDir(""), - mAppRODataDir(""), - mOSUserDir(""), - mOSUserAppDir(""), - mLindenUserDir(""), - mCAFile(""), - mTempDir(""), - mDirDelimiter("") +LLDir::LLDir() +: mDirDelimiter("/") // fallback to forward slash if not overridden { } @@ -125,7 +115,7 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask) const std::string LLDir::findFile(const std::string &filename, const std::string searchPath1, const std::string searchPath2, - const std::string searchPath3) + const std::string searchPath3) const { std::vector search_paths; search_paths.push_back(searchPath1); @@ -246,12 +236,37 @@ const std::string &LLDir::getSkinDir() const return mSkinDir; } +const std::string &LLDir::getUserSkinDir() const +{ + return mUserSkinDir; +} + +const std::string& LLDir::getDefaultSkinDir() const +{ + return mDefaultSkinDir; +} + +const std::string LLDir::getSkinBaseDir() const +{ + std::string dir = getAppRODataDir(); + dir += mDirDelimiter; + dir += "skins"; + + return dir; +} + + std::string LLDir::getExpandedFilename(ELLPath location, const std::string& filename) const { return getExpandedFilename(location, "", filename); } -std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir, const std::string& in_filename) const +std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir, const std::string& filename) const +{ + return getExpandedFilename(location, "", subdir, filename); +} + +std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir1, const std::string& subdir2, const std::string& in_filename) const { std::string prefix; switch (location) @@ -324,13 +339,11 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd prefix += "skins"; break; - case LL_PATH_HTML: - prefix = getAppRODataDir(); - prefix += mDirDelimiter; - prefix += "skins"; - prefix += mDirDelimiter; - prefix += "html"; - break; + //case LL_PATH_HTML: + // prefix = getSkinDir(); + // prefix += mDirDelimiter; + // prefix += "html"; + // break; case LL_PATH_MOZILLA_PROFILE: prefix = getOSUserAppDir(); @@ -343,15 +356,16 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd } std::string filename = in_filename; - if (!subdir.empty()) + if (!subdir2.empty()) { - filename = subdir + mDirDelimiter + in_filename; + filename = subdir2 + mDirDelimiter + filename; } - else + + if (!subdir1.empty()) { - filename = in_filename; + filename = subdir1 + mDirDelimiter + filename; } - + std::string expanded_filename; if (!filename.empty()) { @@ -381,6 +395,31 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd return expanded_filename; } +std::string LLDir::findSkinnedFilename(const std::string &filename) const +{ + return findSkinnedFilename("", "", filename); +} + +std::string LLDir::findSkinnedFilename(const std::string &subdir, const std::string &filename) const +{ + return findSkinnedFilename("", subdir, filename); +} + +std::string LLDir::findSkinnedFilename(const std::string &subdir1, const std::string &subdir2, const std::string &filename) const +{ + // generate subdirectory path fragment, e.g. "/foo/bar", "/foo", "" + std::string subdirs = ((subdir1.empty() ? "" : mDirDelimiter) + subdir1) + + ((subdir2.empty() ? "" : mDirDelimiter) + subdir2); + + std::string found_file = findFile(filename, + getUserSkinDir() + subdirs, // first look in user skin override + getSkinDir() + subdirs, // then in current skin + getDefaultSkinDir() + subdirs); // and last in default skin + + return found_file; +} + + std::string LLDir::getTempFilename() const { LLUUID random_uuid; @@ -464,6 +503,22 @@ void LLDir::setSkinFolder(const std::string &skin_folder) mSkinDir += "skins"; mSkinDir += mDirDelimiter; mSkinDir += skin_folder; + + // user modifications to current skin + // e.g. c:\documents and settings\users\username\application data\second life\skins\dazzle + mUserSkinDir = getOSUserAppDir(); + mUserSkinDir += mDirDelimiter; + mUserSkinDir += "skins"; + mUserSkinDir += mDirDelimiter; + mUserSkinDir += skin_folder; + + // base skin which is used as fallback for all skinned files + // e.g. c:\program files\secondlife\skins\default + mDefaultSkinDir = getAppRODataDir(); + mDefaultSkinDir += mDirDelimiter; + mDefaultSkinDir += "skins"; + mDefaultSkinDir += mDirDelimiter; + mDefaultSkinDir += "default"; } bool LLDir::setCacheDir(const std::string &path) diff --git a/linden/indra/llvfs/lldir.h b/linden/indra/llvfs/lldir.h index c8eeaa2..8734c44 100644 --- a/linden/indra/llvfs/lldir.h +++ b/linden/indra/llvfs/lldir.h @@ -32,6 +32,7 @@ #ifndef LL_LLDIR_H #define LL_LLDIR_H +// these numbers *may* get serialized, so we need to be explicit typedef enum ELLPath { LL_PATH_NONE = 0, @@ -49,8 +50,8 @@ typedef enum ELLPath LL_PATH_CHAT_LOGS = 12, LL_PATH_PER_ACCOUNT_CHAT_LOGS = 13, LL_PATH_MOZILLA_PROFILE = 14, - LL_PATH_HTML = 15, - LL_PATH_COUNT = 16 +// LL_PATH_HTML = 15, + LL_PATH_LAST = 16 } ELLPath; @@ -69,9 +70,9 @@ class LLDir virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) = 0; virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) = 0; virtual std::string getCurPath() = 0; - virtual BOOL fileExists(const std::string &filename) = 0; + virtual BOOL fileExists(const std::string &filename) const = 0; - const std::string findFile(const std::string &filename, const std::string searchPath1 = "", const std::string searchPath2 = "", const std::string searchPath3 = ""); + const std::string findFile(const std::string &filename, const std::string searchPath1 = "", const std::string searchPath2 = "", const std::string searchPath3 = "") const; const std::string &getExecutablePathAndName() const; // Full pathname of the executable const std::string &getAppName() const; // install directory under progams/ ie "SecondLife" const std::string &getExecutableDir() const; // Directory where the executable is located @@ -88,10 +89,21 @@ class LLDir const std::string &getCAFile() const; // File containing TLS certificate authorities const std::string &getDirDelimiter() const; // directory separator for platform (ie. '\' or '/' or ':') const std::string &getSkinDir() const; // User-specified skin folder. + const std::string &getUserSkinDir() const; // User-specified skin folder with user modifications. e.g. c:\documents and settings\username\application data\second life\skins\curskin + const std::string &getDefaultSkinDir() const; // folder for default skin. e.g. c:\program files\second life\skins\default + const std::string getSkinBaseDir() const; // folder that contains all installed skins (not user modifications). e.g. c:\program files\second life\skins // Expanded filename std::string getExpandedFilename(ELLPath location, const std::string &filename) const; std::string getExpandedFilename(ELLPath location, const std::string &subdir, const std::string &filename) const; + std::string getExpandedFilename(ELLPath location, const std::string &subdir1, const std::string &subdir2, const std::string &filename) const; + + // these methods search the various skin paths for the specified file in the following order: + // getUserSkinDir(), getSkinDir(), getDefaultSkinDir() + std::string findSkinnedFilename(const std::string &filename) const; + std::string findSkinnedFilename(const std::string &subdir, const std::string &filename) const; + std::string findSkinnedFilename(const std::string &subdir1, const std::string &subdir2, const std::string &filename) const; + // random filename in common temporary directory std::string getTempFilename() const; @@ -120,7 +132,9 @@ protected: std::string mTempDir; std::string mCacheDir; std::string mDirDelimiter; - std::string mSkinDir; // Location for u ser-specified skin info. + std::string mSkinDir; // Location for current skin info. + std::string mDefaultSkinDir; // Location for default skin info. + std::string mUserSkinDir; // Location for user-modified skin info. }; void dir_exists_or_crash(const std::string &dir_name); diff --git a/linden/indra/llvfs/lldir_linux.cpp b/linden/indra/llvfs/lldir_linux.cpp index 0e4e0a2..9aa4da3 100644 --- a/linden/indra/llvfs/lldir_linux.cpp +++ b/linden/indra/llvfs/lldir_linux.cpp @@ -349,7 +349,7 @@ std::string LLDir_Linux::getCurPath() } -BOOL LLDir_Linux::fileExists(const std::string &filename) +BOOL LLDir_Linux::fileExists(const std::string &filename) const { struct stat stat_data; // Check the age of the file diff --git a/linden/indra/llvfs/lldir_linux.h b/linden/indra/llvfs/lldir_linux.h index 4815fe9..99925c1 100644 --- a/linden/indra/llvfs/lldir_linux.h +++ b/linden/indra/llvfs/lldir_linux.h @@ -49,7 +49,7 @@ public: virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap); virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname); - /*virtual*/ BOOL fileExists(const std::string &filename); + /*virtual*/ BOOL fileExists(const std::string &filename) const; private: DIR *mDirp; diff --git a/linden/indra/llvfs/lldir_mac.cpp b/linden/indra/llvfs/lldir_mac.cpp index f67a487..8b1be53 100644 --- a/linden/indra/llvfs/lldir_mac.cpp +++ b/linden/indra/llvfs/lldir_mac.cpp @@ -361,7 +361,7 @@ std::string LLDir_Mac::getCurPath() -BOOL LLDir_Mac::fileExists(const std::string &filename) +BOOL LLDir_Mac::fileExists(const std::string &filename) const { struct stat stat_data; // Check the age of the file diff --git a/linden/indra/llvfs/lldir_mac.h b/linden/indra/llvfs/lldir_mac.h index 73c964d..beb8c93 100644 --- a/linden/indra/llvfs/lldir_mac.h +++ b/linden/indra/llvfs/lldir_mac.h @@ -49,7 +49,7 @@ public: virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap); virtual void getRandomFileInDir(const std::string &dirname, const std::string &ask, std::string &fname); - virtual BOOL fileExists(const std::string &filename); + virtual BOOL fileExists(const std::string &filename) const; private: int mCurrentDirIndex; diff --git a/linden/indra/llvfs/lldir_win32.cpp b/linden/indra/llvfs/lldir_win32.cpp index ae87aa1..8904dff 100644 --- a/linden/indra/llvfs/lldir_win32.cpp +++ b/linden/indra/llvfs/lldir_win32.cpp @@ -338,7 +338,7 @@ std::string LLDir_Win32::getCurPath() } -BOOL LLDir_Win32::fileExists(const std::string &filename) +BOOL LLDir_Win32::fileExists(const std::string &filename) const { llstat stat_data; // Check the age of the file diff --git a/linden/indra/llvfs/lldir_win32.h b/linden/indra/llvfs/lldir_win32.h index 2744ea2..e988d39 100644 --- a/linden/indra/llvfs/lldir_win32.h +++ b/linden/indra/llvfs/lldir_win32.h @@ -46,7 +46,7 @@ public: /*virtual*/ U32 countFilesInDir(const std::string &dirname, const std::string &mask); /*virtual*/ BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap); /*virtual*/ void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname); - /*virtual*/ BOOL fileExists(const std::string &filename); + /*virtual*/ BOOL fileExists(const std::string &filename) const; private: BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::string &mask, std::string &fname, BOOL wrap); -- cgit v1.1