diff options
Diffstat (limited to 'linden/indra/llvfs/lldir.cpp')
-rw-r--r-- | linden/indra/llvfs/lldir.cpp | 107 |
1 files changed, 81 insertions, 26 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 | ||
60 | LLDir *gDirUtilp = (LLDir *)&gDirUtil; | 60 | LLDir *gDirUtilp = (LLDir *)&gDirUtil; |
61 | 61 | ||
62 | LLDir::LLDir() | 62 | LLDir::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) | |||
125 | const std::string LLDir::findFile(const std::string &filename, | 115 | const 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 | ||
239 | const std::string &LLDir::getUserSkinDir() const | ||
240 | { | ||
241 | return mUserSkinDir; | ||
242 | } | ||
243 | |||
244 | const std::string& LLDir::getDefaultSkinDir() const | ||
245 | { | ||
246 | return mDefaultSkinDir; | ||
247 | } | ||
248 | |||
249 | const std::string LLDir::getSkinBaseDir() const | ||
250 | { | ||
251 | std::string dir = getAppRODataDir(); | ||
252 | dir += mDirDelimiter; | ||
253 | dir += "skins"; | ||
254 | |||
255 | return dir; | ||
256 | } | ||
257 | |||
258 | |||
249 | std::string LLDir::getExpandedFilename(ELLPath location, const std::string& filename) const | 259 | std::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 | ||
254 | std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir, const std::string& in_filename) const | 264 | std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir, const std::string& filename) const |
265 | { | ||
266 | return getExpandedFilename(location, "", subdir, filename); | ||
267 | } | ||
268 | |||
269 | std::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 | ||
398 | std::string LLDir::findSkinnedFilename(const std::string &filename) const | ||
399 | { | ||
400 | return findSkinnedFilename("", "", filename); | ||
401 | } | ||
402 | |||
403 | std::string LLDir::findSkinnedFilename(const std::string &subdir, const std::string &filename) const | ||
404 | { | ||
405 | return findSkinnedFilename("", subdir, filename); | ||
406 | } | ||
407 | |||
408 | std::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 | |||
384 | std::string LLDir::getTempFilename() const | 423 | std::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 | ||
469 | bool LLDir::setCacheDir(const std::string &path) | 524 | bool LLDir::setCacheDir(const std::string &path) |