diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-07-22 19:01:52 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-07-22 19:01:52 +0000 |
commit | 0c0391cc7114bd2e9e4462c40e88814326f61bc2 (patch) | |
tree | 2906124fe8371b6336e6f7231cd890d267a75d6d /indra/llvfs | |
parent | ed386ae547c225e352c39e8d14921572ee534b0b (diff) |
QAR-758 1.20 Viewer RC 12, 13, 14, 15 -> Release
merge Branch_1-20-14-Viewer-merge -> release
Includes Branch_1-20-Viewer-2 through 92456
Diffstat (limited to 'indra/llvfs')
-rw-r--r-- | indra/llvfs/lldir.cpp | 106 | ||||
-rw-r--r-- | indra/llvfs/lldir.h | 23 | ||||
-rw-r--r-- | indra/llvfs/lldir_linux.cpp | 2 | ||||
-rw-r--r-- | indra/llvfs/lldir_linux.h | 2 | ||||
-rw-r--r-- | indra/llvfs/lldir_mac.cpp | 2 | ||||
-rw-r--r-- | indra/llvfs/lldir_mac.h | 2 | ||||
-rw-r--r-- | indra/llvfs/lldir_win32.cpp | 2 | ||||
-rw-r--r-- | indra/llvfs/lldir_win32.h | 2 |
8 files changed, 104 insertions, 37 deletions
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index 766c1c85b4..f4865202d5 100644 --- a/indra/llvfs/lldir.cpp +++ b/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<std::string> 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()) { @@ -415,6 +429,30 @@ std::string LLDir::getExtension(const std::string& filepath) const return exten; } +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; @@ -498,6 +536,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/indra/llvfs/lldir.h b/indra/llvfs/lldir.h index 6e7166c81d..93b15276a3 100644 --- a/indra/llvfs/lldir.h +++ b/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,16 +89,26 @@ 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; // Base and Directory name extraction std::string getBaseFileName(const std::string& filepath, bool strip_exten = false) const; std::string getDirName(const std::string& filepath) const; std::string getExtension(const std::string& filepath) const; // Excludes '.', e.g getExtension("foo.wav") == "wav" + // 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; @@ -125,7 +136,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/indra/llvfs/lldir_linux.cpp b/indra/llvfs/lldir_linux.cpp index 7fa30b0ff1..cac32f864d 100644 --- a/indra/llvfs/lldir_linux.cpp +++ b/indra/llvfs/lldir_linux.cpp @@ -353,7 +353,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/indra/llvfs/lldir_linux.h b/indra/llvfs/lldir_linux.h index a81df89807..ac52bb573e 100644 --- a/indra/llvfs/lldir_linux.h +++ b/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/indra/llvfs/lldir_mac.cpp b/indra/llvfs/lldir_mac.cpp index 3cf70d76c2..80134e2978 100644 --- a/indra/llvfs/lldir_mac.cpp +++ b/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/indra/llvfs/lldir_mac.h b/indra/llvfs/lldir_mac.h index c1244a2fa8..6fb2df0c96 100644 --- a/indra/llvfs/lldir_mac.h +++ b/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/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp index 0632813b15..d21babec24 100644 --- a/indra/llvfs/lldir_win32.cpp +++ b/indra/llvfs/lldir_win32.cpp @@ -344,7 +344,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/indra/llvfs/lldir_win32.h b/indra/llvfs/lldir_win32.h index bddf17503b..70cbec2897 100644 --- a/indra/llvfs/lldir_win32.h +++ b/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); |