aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llvfs/lldir.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/llvfs/lldir.cpp
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to '')
-rw-r--r--linden/indra/llvfs/lldir.cpp78
1 files changed, 64 insertions, 14 deletions
diff --git a/linden/indra/llvfs/lldir.cpp b/linden/indra/llvfs/lldir.cpp
index b0d9d92..6d0e956 100644
--- a/linden/indra/llvfs/lldir.cpp
+++ b/linden/indra/llvfs/lldir.cpp
@@ -202,6 +202,27 @@ const std::string &LLDir::getTempDir() const
202 return mTempDir; 202 return mTempDir;
203} 203}
204 204
205const std::string LLDir::getCacheDir(bool get_default) const
206{
207 if (mCacheDir.empty() || get_default)
208 {
209 std::string res;
210 if (getOSUserAppDir().empty())
211 {
212 res = "data";
213 }
214 else
215 {
216 res = getOSUserAppDir() + mDirDelimiter + "cache";
217 }
218 return res;
219 }
220 else
221 {
222 return mCacheDir;
223 }
224}
225
205const std::string &LLDir::getCAFile() const 226const std::string &LLDir::getCAFile() const
206{ 227{
207 return mCAFile; 228 return mCAFile;
@@ -217,7 +238,12 @@ const std::string &LLDir::getSkinDir() const
217 return mSkinDir; 238 return mSkinDir;
218} 239}
219 240
220std::string LLDir::getExpandedFilename(ELLPath location, const std::string &filename) const 241std::string LLDir::getExpandedFilename(ELLPath location, const std::string& filename) const
242{
243 return getExpandedFilename(location, "", filename);
244}
245
246std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir, const std::string& in_filename) const
221{ 247{
222 std::string prefix; 248 std::string prefix;
223 switch (location) 249 switch (location)
@@ -249,16 +275,7 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string &file
249 break; 275 break;
250 276
251 case LL_PATH_CACHE: 277 case LL_PATH_CACHE:
252 if (getOSUserAppDir().empty()) 278 prefix = getCacheDir();
253 {
254 prefix = "data";
255 }
256 else
257 {
258 prefix = getOSUserAppDir();
259 prefix += mDirDelimiter;
260 prefix += "cache";
261 }
262 break; 279 break;
263 280
264 case LL_PATH_USER_SETTINGS: 281 case LL_PATH_USER_SETTINGS:
@@ -309,6 +326,16 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string &file
309 llassert(0); 326 llassert(0);
310 } 327 }
311 328
329 std::string filename = in_filename;
330 if (!subdir.empty())
331 {
332 filename = subdir + mDirDelimiter + in_filename;
333 }
334 else
335 {
336 filename = in_filename;
337 }
338
312 std::string expanded_filename; 339 std::string expanded_filename;
313 if (!filename.empty()) 340 if (!filename.empty())
314 { 341 {
@@ -323,8 +350,7 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string &file
323 expanded_filename = filename; 350 expanded_filename = filename;
324 } 351 }
325 } 352 }
326 else 353 else if (!prefix.empty())
327 if (!prefix.empty())
328 { 354 {
329 // Directory only, no file name. 355 // Directory only, no file name.
330 expanded_filename = prefix; 356 expanded_filename = prefix;
@@ -342,7 +368,7 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string &file
342std::string LLDir::getTempFilename() const 368std::string LLDir::getTempFilename() const
343{ 369{
344 LLUUID random_uuid; 370 LLUUID random_uuid;
345 char uuid_str[64]; 371 char uuid_str[64]; /* Flawfinder: ignore */
346 372
347 random_uuid.generate(); 373 random_uuid.generate();
348 random_uuid.toString(uuid_str); 374 random_uuid.toString(uuid_str);
@@ -424,6 +450,30 @@ void LLDir::setSkinFolder(const std::string &skin_folder)
424 mSkinDir += skin_folder; 450 mSkinDir += skin_folder;
425} 451}
426 452
453bool LLDir::setCacheDir(const std::string &path)
454{
455 if (path.empty() )
456 {
457 // reset to default
458 mCacheDir = "";
459 return true;
460 }
461 else
462 {
463 LLFile::mkdir(path.c_str());
464 std::string tempname = path + mDirDelimiter + "temp";
465 LLFILE* file = LLFile::fopen(tempname.c_str(),"wt");
466 if (file)
467 {
468 fclose(file);
469 LLFile::remove(tempname.c_str());
470 mCacheDir = path;
471 return true;
472 }
473 return false;
474 }
475}
476
427void LLDir::dumpCurrentDirectories() 477void LLDir::dumpCurrentDirectories()
428{ 478{
429 llinfos << "Current Directories:" << llendl; 479 llinfos << "Current Directories:" << llendl;