aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llvfs
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:59 -0500
committerJacek Antonelli2008-08-15 23:45:59 -0500
commit6e91a9cc3d5a610198cf526a76e2ab642f10ecd7 (patch)
treeb023869f9daa7f61ea3ab27112d37524bdd88de4 /linden/indra/llvfs
parentSecond Life viewer sources 1.20.12 (diff)
downloadmeta-impy-6e91a9cc3d5a610198cf526a76e2ab642f10ecd7.zip
meta-impy-6e91a9cc3d5a610198cf526a76e2ab642f10ecd7.tar.gz
meta-impy-6e91a9cc3d5a610198cf526a76e2ab642f10ecd7.tar.bz2
meta-impy-6e91a9cc3d5a610198cf526a76e2ab642f10ecd7.tar.xz
Second Life viewer sources 1.20.13
Diffstat (limited to 'linden/indra/llvfs')
-rw-r--r--linden/indra/llvfs/lldir.cpp107
-rw-r--r--linden/indra/llvfs/lldir.h24
-rw-r--r--linden/indra/llvfs/lldir_linux.cpp2
-rw-r--r--linden/indra/llvfs/lldir_linux.h2
-rw-r--r--linden/indra/llvfs/lldir_mac.cpp2
-rw-r--r--linden/indra/llvfs/lldir_mac.h2
-rw-r--r--linden/indra/llvfs/lldir_win32.cpp2
-rw-r--r--linden/indra/llvfs/lldir_win32.h2
8 files changed, 106 insertions, 37 deletions
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;
59 59
60LLDir *gDirUtilp = (LLDir *)&gDirUtil; 60LLDir *gDirUtilp = (LLDir *)&gDirUtil;
61 61
62LLDir::LLDir() 62LLDir::LLDir()
63: mAppName(""), 63: mDirDelimiter("/") // fallback to forward slash if not overridden
64 mExecutablePathAndName(""),
65 mExecutableFilename(""),
66 mExecutableDir(""),
67 mAppRODataDir(""),
68 mOSUserDir(""),
69 mOSUserAppDir(""),
70 mLindenUserDir(""),
71 mCAFile(""),
72 mTempDir(""),
73 mDirDelimiter("")
74{ 64{
75} 65}
76 66
@@ -125,7 +115,7 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask)
125const std::string LLDir::findFile(const std::string &filename, 115const std::string LLDir::findFile(const std::string &filename,
126 const std::string searchPath1, 116 const std::string searchPath1,
127 const std::string searchPath2, 117 const std::string searchPath2,
128 const std::string searchPath3) 118 const std::string searchPath3) const
129{ 119{
130 std::vector<std::string> search_paths; 120 std::vector<std::string> search_paths;
131 search_paths.push_back(searchPath1); 121 search_paths.push_back(searchPath1);
@@ -246,12 +236,37 @@ const std::string &LLDir::getSkinDir() const
246 return mSkinDir; 236 return mSkinDir;
247} 237}
248 238
239const std::string &LLDir::getUserSkinDir() const
240{
241 return mUserSkinDir;
242}
243
244const std::string& LLDir::getDefaultSkinDir() const
245{
246 return mDefaultSkinDir;
247}
248
249const std::string LLDir::getSkinBaseDir() const
250{
251 std::string dir = getAppRODataDir();
252 dir += mDirDelimiter;
253 dir += "skins";
254
255 return dir;
256}
257
258
249std::string LLDir::getExpandedFilename(ELLPath location, const std::string& filename) const 259std::string LLDir::getExpandedFilename(ELLPath location, const std::string& filename) const
250{ 260{
251 return getExpandedFilename(location, "", filename); 261 return getExpandedFilename(location, "", filename);
252} 262}
253 263
254std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir, const std::string& in_filename) const 264std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir, const std::string& filename) const
265{
266 return getExpandedFilename(location, "", subdir, filename);
267}
268
269std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir1, const std::string& subdir2, const std::string& in_filename) const
255{ 270{
256 std::string prefix; 271 std::string prefix;
257 switch (location) 272 switch (location)
@@ -324,13 +339,11 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
324 prefix += "skins"; 339 prefix += "skins";
325 break; 340 break;
326 341
327 case LL_PATH_HTML: 342 //case LL_PATH_HTML:
328 prefix = getAppRODataDir(); 343 // prefix = getSkinDir();
329 prefix += mDirDelimiter; 344 // prefix += mDirDelimiter;
330 prefix += "skins"; 345 // prefix += "html";
331 prefix += mDirDelimiter; 346 // break;
332 prefix += "html";
333 break;
334 347
335 case LL_PATH_MOZILLA_PROFILE: 348 case LL_PATH_MOZILLA_PROFILE:
336 prefix = getOSUserAppDir(); 349 prefix = getOSUserAppDir();
@@ -343,15 +356,16 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
343 } 356 }
344 357
345 std::string filename = in_filename; 358 std::string filename = in_filename;
346 if (!subdir.empty()) 359 if (!subdir2.empty())
347 { 360 {
348 filename = subdir + mDirDelimiter + in_filename; 361 filename = subdir2 + mDirDelimiter + filename;
349 } 362 }
350 else 363
364 if (!subdir1.empty())
351 { 365 {
352 filename = in_filename; 366 filename = subdir1 + mDirDelimiter + filename;
353 } 367 }
354 368
355 std::string expanded_filename; 369 std::string expanded_filename;
356 if (!filename.empty()) 370 if (!filename.empty())
357 { 371 {
@@ -381,6 +395,31 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
381 return expanded_filename; 395 return expanded_filename;
382} 396}
383 397
398std::string LLDir::findSkinnedFilename(const std::string &filename) const
399{
400 return findSkinnedFilename("", "", filename);
401}
402
403std::string LLDir::findSkinnedFilename(const std::string &subdir, const std::string &filename) const
404{
405 return findSkinnedFilename("", subdir, filename);
406}
407
408std::string LLDir::findSkinnedFilename(const std::string &subdir1, const std::string &subdir2, const std::string &filename) const
409{
410 // generate subdirectory path fragment, e.g. "/foo/bar", "/foo", ""
411 std::string subdirs = ((subdir1.empty() ? "" : mDirDelimiter) + subdir1)
412 + ((subdir2.empty() ? "" : mDirDelimiter) + subdir2);
413
414 std::string found_file = findFile(filename,
415 getUserSkinDir() + subdirs, // first look in user skin override
416 getSkinDir() + subdirs, // then in current skin
417 getDefaultSkinDir() + subdirs); // and last in default skin
418
419 return found_file;
420}
421
422
384std::string LLDir::getTempFilename() const 423std::string LLDir::getTempFilename() const
385{ 424{
386 LLUUID random_uuid; 425 LLUUID random_uuid;
@@ -464,6 +503,22 @@ void LLDir::setSkinFolder(const std::string &skin_folder)
464 mSkinDir += "skins"; 503 mSkinDir += "skins";
465 mSkinDir += mDirDelimiter; 504 mSkinDir += mDirDelimiter;
466 mSkinDir += skin_folder; 505 mSkinDir += skin_folder;
506
507 // user modifications to current skin
508 // e.g. c:\documents and settings\users\username\application data\second life\skins\dazzle
509 mUserSkinDir = getOSUserAppDir();
510 mUserSkinDir += mDirDelimiter;
511 mUserSkinDir += "skins";
512 mUserSkinDir += mDirDelimiter;
513 mUserSkinDir += skin_folder;
514
515 // base skin which is used as fallback for all skinned files
516 // e.g. c:\program files\secondlife\skins\default
517 mDefaultSkinDir = getAppRODataDir();
518 mDefaultSkinDir += mDirDelimiter;
519 mDefaultSkinDir += "skins";
520 mDefaultSkinDir += mDirDelimiter;
521 mDefaultSkinDir += "default";
467} 522}
468 523
469bool LLDir::setCacheDir(const std::string &path) 524bool 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 @@
32#ifndef LL_LLDIR_H 32#ifndef LL_LLDIR_H
33#define LL_LLDIR_H 33#define LL_LLDIR_H
34 34
35// these numbers *may* get serialized, so we need to be explicit
35typedef enum ELLPath 36typedef enum ELLPath
36{ 37{
37 LL_PATH_NONE = 0, 38 LL_PATH_NONE = 0,
@@ -49,8 +50,8 @@ typedef enum ELLPath
49 LL_PATH_CHAT_LOGS = 12, 50 LL_PATH_CHAT_LOGS = 12,
50 LL_PATH_PER_ACCOUNT_CHAT_LOGS = 13, 51 LL_PATH_PER_ACCOUNT_CHAT_LOGS = 13,
51 LL_PATH_MOZILLA_PROFILE = 14, 52 LL_PATH_MOZILLA_PROFILE = 14,
52 LL_PATH_HTML = 15, 53// LL_PATH_HTML = 15,
53 LL_PATH_COUNT = 16 54 LL_PATH_LAST = 16
54} ELLPath; 55} ELLPath;
55 56
56 57
@@ -69,9 +70,9 @@ class LLDir
69 virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) = 0; 70 virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) = 0;
70 virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) = 0; 71 virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) = 0;
71 virtual std::string getCurPath() = 0; 72 virtual std::string getCurPath() = 0;
72 virtual BOOL fileExists(const std::string &filename) = 0; 73 virtual BOOL fileExists(const std::string &filename) const = 0;
73 74
74 const std::string findFile(const std::string &filename, const std::string searchPath1 = "", const std::string searchPath2 = "", const std::string searchPath3 = ""); 75 const std::string findFile(const std::string &filename, const std::string searchPath1 = "", const std::string searchPath2 = "", const std::string searchPath3 = "") const;
75 const std::string &getExecutablePathAndName() const; // Full pathname of the executable 76 const std::string &getExecutablePathAndName() const; // Full pathname of the executable
76 const std::string &getAppName() const; // install directory under progams/ ie "SecondLife" 77 const std::string &getAppName() const; // install directory under progams/ ie "SecondLife"
77 const std::string &getExecutableDir() const; // Directory where the executable is located 78 const std::string &getExecutableDir() const; // Directory where the executable is located
@@ -88,10 +89,21 @@ class LLDir
88 const std::string &getCAFile() const; // File containing TLS certificate authorities 89 const std::string &getCAFile() const; // File containing TLS certificate authorities
89 const std::string &getDirDelimiter() const; // directory separator for platform (ie. '\' or '/' or ':') 90 const std::string &getDirDelimiter() const; // directory separator for platform (ie. '\' or '/' or ':')
90 const std::string &getSkinDir() const; // User-specified skin folder. 91 const std::string &getSkinDir() const; // User-specified skin folder.
92 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
93 const std::string &getDefaultSkinDir() const; // folder for default skin. e.g. c:\program files\second life\skins\default
94 const std::string getSkinBaseDir() const; // folder that contains all installed skins (not user modifications). e.g. c:\program files\second life\skins
91 95
92 // Expanded filename 96 // Expanded filename
93 std::string getExpandedFilename(ELLPath location, const std::string &filename) const; 97 std::string getExpandedFilename(ELLPath location, const std::string &filename) const;
94 std::string getExpandedFilename(ELLPath location, const std::string &subdir, const std::string &filename) const; 98 std::string getExpandedFilename(ELLPath location, const std::string &subdir, const std::string &filename) const;
99 std::string getExpandedFilename(ELLPath location, const std::string &subdir1, const std::string &subdir2, const std::string &filename) const;
100
101 // these methods search the various skin paths for the specified file in the following order:
102 // getUserSkinDir(), getSkinDir(), getDefaultSkinDir()
103 std::string findSkinnedFilename(const std::string &filename) const;
104 std::string findSkinnedFilename(const std::string &subdir, const std::string &filename) const;
105 std::string findSkinnedFilename(const std::string &subdir1, const std::string &subdir2, const std::string &filename) const;
106
95 107
96 // random filename in common temporary directory 108 // random filename in common temporary directory
97 std::string getTempFilename() const; 109 std::string getTempFilename() const;
@@ -120,7 +132,9 @@ protected:
120 std::string mTempDir; 132 std::string mTempDir;
121 std::string mCacheDir; 133 std::string mCacheDir;
122 std::string mDirDelimiter; 134 std::string mDirDelimiter;
123 std::string mSkinDir; // Location for u ser-specified skin info. 135 std::string mSkinDir; // Location for current skin info.
136 std::string mDefaultSkinDir; // Location for default skin info.
137 std::string mUserSkinDir; // Location for user-modified skin info.
124}; 138};
125 139
126void dir_exists_or_crash(const std::string &dir_name); 140void 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()
349} 349}
350 350
351 351
352BOOL LLDir_Linux::fileExists(const std::string &filename) 352BOOL LLDir_Linux::fileExists(const std::string &filename) const
353{ 353{
354 struct stat stat_data; 354 struct stat stat_data;
355 // Check the age of the file 355 // 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:
49 virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); 49 virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask);
50 virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap); 50 virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap);
51 virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname); 51 virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname);
52 /*virtual*/ BOOL fileExists(const std::string &filename); 52 /*virtual*/ BOOL fileExists(const std::string &filename) const;
53 53
54private: 54private:
55 DIR *mDirp; 55 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()
361 361
362 362
363 363
364BOOL LLDir_Mac::fileExists(const std::string &filename) 364BOOL LLDir_Mac::fileExists(const std::string &filename) const
365{ 365{
366 struct stat stat_data; 366 struct stat stat_data;
367 // Check the age of the file 367 // 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:
49 virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); 49 virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask);
50 virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap); 50 virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap);
51 virtual void getRandomFileInDir(const std::string &dirname, const std::string &ask, std::string &fname); 51 virtual void getRandomFileInDir(const std::string &dirname, const std::string &ask, std::string &fname);
52 virtual BOOL fileExists(const std::string &filename); 52 virtual BOOL fileExists(const std::string &filename) const;
53 53
54private: 54private:
55 int mCurrentDirIndex; 55 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()
338} 338}
339 339
340 340
341BOOL LLDir_Win32::fileExists(const std::string &filename) 341BOOL LLDir_Win32::fileExists(const std::string &filename) const
342{ 342{
343 llstat stat_data; 343 llstat stat_data;
344 // Check the age of the file 344 // 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:
46 /*virtual*/ U32 countFilesInDir(const std::string &dirname, const std::string &mask); 46 /*virtual*/ U32 countFilesInDir(const std::string &dirname, const std::string &mask);
47 /*virtual*/ BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap); 47 /*virtual*/ BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap);
48 /*virtual*/ void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname); 48 /*virtual*/ void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname);
49 /*virtual*/ BOOL fileExists(const std::string &filename); 49 /*virtual*/ BOOL fileExists(const std::string &filename) const;
50 50
51private: 51private:
52 BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::string &mask, std::string &fname, BOOL wrap); 52 BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::string &mask, std::string &fname, BOOL wrap);