summaryrefslogtreecommitdiff
path: root/indra/llfilesystem
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llfilesystem')
-rw-r--r--indra/llfilesystem/CMakeLists.txt31
-rw-r--r--indra/llfilesystem/lldir_mac.cpp32
-rw-r--r--indra/llfilesystem/lldir_utils_objc.h10
-rw-r--r--indra/llfilesystem/lldir_utils_objc.mm82
-rw-r--r--indra/llfilesystem/lldiskcache.cpp51
5 files changed, 92 insertions, 114 deletions
diff --git a/indra/llfilesystem/CMakeLists.txt b/indra/llfilesystem/CMakeLists.txt
index 09c4c33ebf..9f24f75eab 100644
--- a/indra/llfilesystem/CMakeLists.txt
+++ b/indra/llfilesystem/CMakeLists.txt
@@ -4,12 +4,6 @@ project(llfilesystem)
include(00-Common)
include(LLCommon)
-include(UnixInstall)
-
-include_directories(
- ${LLCOMMON_INCLUDE_DIRS}
- ${LLCOMMON_SYSTEM_INCLUDE_DIRS}
- )
set(llfilesystem_SOURCE_FILES
lldir.cpp
@@ -53,29 +47,14 @@ if (WINDOWS)
LIST(APPEND llfilesystem_HEADER_FILES lldir_win32.h)
endif (WINDOWS)
-set_source_files_properties(${llfilesystem_HEADER_FILES}
- PROPERTIES HEADER_FILE_ONLY TRUE)
-
list(APPEND llfilesystem_SOURCE_FILES ${llfilesystem_HEADER_FILES})
add_library (llfilesystem ${llfilesystem_SOURCE_FILES})
-set(cache_BOOST_LIBRARIES
- ${BOOST_FILESYSTEM_LIBRARY}
- ${BOOST_SYSTEM_LIBRARY}
- )
-
target_link_libraries(llfilesystem
- ${LLCOMMON_LIBRARIES}
- ${cache_BOOST_LIBRARIES}
+ llcommon
)
-
-if (DARWIN)
- include(CMakeFindFrameworks)
- find_library(COCOA_LIBRARY Cocoa)
- target_link_libraries(llfilesystem ${COCOA_LIBRARY})
-endif (DARWIN)
-
+target_include_directories( llfilesystem INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
# Add tests
if (LL_TESTS)
@@ -85,14 +64,10 @@ if (LL_TESTS)
lldiriterator.cpp
)
- set_source_files_properties(lldiriterator.cpp
- PROPERTIES
- LL_TEST_ADDITIONAL_LIBRARIES "${cache_BOOST_LIBRARIES}"
- )
LL_ADD_PROJECT_UNIT_TESTS(llfilesystem "${llfilesystem_TEST_SOURCE_FILES}")
# INTEGRATION TESTS
- set(test_libs llmath llcommon llfilesystem ${LLCOMMON_LIBRARIES} ${WINDOWS_LIBRARIES})
+ set(test_libs llmath llcommon llfilesystem )
# TODO: Some of these need refactoring to be proper Unit tests rather than Integration tests.
LL_ADD_INTEGRATION_TEST(lldir "" "${test_libs}")
diff --git a/indra/llfilesystem/lldir_mac.cpp b/indra/llfilesystem/lldir_mac.cpp
index 3bc4ee844e..9ad8e274b6 100644
--- a/indra/llfilesystem/lldir_mac.cpp
+++ b/indra/llfilesystem/lldir_mac.cpp
@@ -66,16 +66,16 @@ LLDir_Mac::LLDir_Mac()
const std::string secondLifeString = "SecondLife";
- std::string *executablepathstr = getSystemExecutableFolder();
+ std::string executablepathstr = getSystemExecutableFolder();
//NOTE: LLINFOS/LLERRS will not output to log here. The streams are not initialized.
- if (executablepathstr)
+ if (!executablepathstr.empty())
{
// mExecutablePathAndName
- mExecutablePathAndName = *executablepathstr;
+ mExecutablePathAndName = executablepathstr;
- boost::filesystem::path executablepath(*executablepathstr);
+ boost::filesystem::path executablepath(executablepathstr);
# ifndef BOOST_SYSTEM_NO_DEPRECATED
#endif
@@ -83,8 +83,8 @@ LLDir_Mac::LLDir_Mac()
mExecutableDir = executablepath.parent_path().string();
// mAppRODataDir
- std::string *resourcepath = getSystemResourceFolder();
- mAppRODataDir = *resourcepath;
+ std::string resourcepath = getSystemResourceFolder();
+ mAppRODataDir = resourcepath;
// *NOTE: When running in a dev tree, use the copy of
// skins in indra/newview/ rather than in the application bundle. This
@@ -110,11 +110,11 @@ LLDir_Mac::LLDir_Mac()
}
// mOSUserDir
- std::string *appdir = getSystemApplicationSupportFolder();
+ std::string appdir = getSystemApplicationSupportFolder();
std::string rootdir;
//Create root directory
- if (CreateDirectory(*appdir, secondLifeString, &rootdir))
+ if (CreateDirectory(appdir, secondLifeString, &rootdir))
{
// Save the full path to the folder
@@ -128,12 +128,10 @@ LLDir_Mac::LLDir_Mac()
}
//mOSCacheDir
- std::string *cachedir = getSystemCacheFolder();
-
- if (cachedir)
-
+ std::string cachedir = getSystemCacheFolder();
+ if (!cachedir.empty())
{
- mOSCacheDir = *cachedir;
+ mOSCacheDir = cachedir;
//TODO: This changes from ~/Library/Cache/Secondlife to ~/Library/Cache/com.app.secondlife/Secondlife. Last dir level could go away.
CreateDirectory(mOSCacheDir, secondLifeString, NULL);
}
@@ -143,12 +141,10 @@ LLDir_Mac::LLDir_Mac()
// mTempDir
//Aura 120920 boost::filesystem::temp_directory_path() not yet implemented on mac. :(
- std::string *tmpdir = getSystemTempFolder();
- if (tmpdir)
+ std::string tmpdir = getSystemTempFolder();
+ if (!tmpdir.empty())
{
-
- CreateDirectory(*tmpdir, secondLifeString, &mTempDir);
- if (tmpdir) delete tmpdir;
+ CreateDirectory(tmpdir, secondLifeString, &mTempDir);
}
mWorkingDir = getCurPath();
diff --git a/indra/llfilesystem/lldir_utils_objc.h b/indra/llfilesystem/lldir_utils_objc.h
index 12019c4284..59dbeb4aec 100644
--- a/indra/llfilesystem/lldir_utils_objc.h
+++ b/indra/llfilesystem/lldir_utils_objc.h
@@ -33,11 +33,11 @@
#include <iostream>
-std::string* getSystemTempFolder();
-std::string* getSystemCacheFolder();
-std::string* getSystemApplicationSupportFolder();
-std::string* getSystemResourceFolder();
-std::string* getSystemExecutableFolder();
+std::string getSystemTempFolder();
+std::string getSystemCacheFolder();
+std::string getSystemApplicationSupportFolder();
+std::string getSystemResourceFolder();
+std::string getSystemExecutableFolder();
#endif // LL_LLDIR_UTILS_OBJC_H
diff --git a/indra/llfilesystem/lldir_utils_objc.mm b/indra/llfilesystem/lldir_utils_objc.mm
index da55a2f897..20540fb93c 100644
--- a/indra/llfilesystem/lldir_utils_objc.mm
+++ b/indra/llfilesystem/lldir_utils_objc.mm
@@ -30,75 +30,75 @@
#include "lldir_utils_objc.h"
#import <Cocoa/Cocoa.h>
-std::string* getSystemTempFolder()
+std::string getSystemTempFolder()
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSString * tempDir = NSTemporaryDirectory();
- if (tempDir == nil)
- tempDir = @"/tmp";
- std::string *result = ( new std::string([tempDir UTF8String]) );
- [pool release];
+ std::string result;
+ @autoreleasepool {
+ NSString * tempDir = NSTemporaryDirectory();
+ if (tempDir == nil)
+ tempDir = @"/tmp";
+ result = std::string([tempDir UTF8String]);
+ }
return result;
}
//findSystemDirectory scoped exclusively to this file.
-std::string* findSystemDirectory(NSSearchPathDirectory searchPathDirectory,
+std::string findSystemDirectory(NSSearchPathDirectory searchPathDirectory,
NSSearchPathDomainMask domainMask)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- std::string *result = nil;
- NSString *path = nil;
-
- // Search for the path
- NSArray* paths = NSSearchPathForDirectoriesInDomains(searchPathDirectory,
- domainMask,
- YES);
- if ([paths count])
- {
- path = [paths objectAtIndex:0];
- //HACK: Always attempt to create directory, ignore errors.
- NSError *error = nil;
-
- [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
-
+ std::string result;
+ @autoreleasepool {
+ NSString *path = nil;
- result = new std::string([path UTF8String]);
+ // Search for the path
+ NSArray* paths = NSSearchPathForDirectoriesInDomains(searchPathDirectory,
+ domainMask,
+ YES);
+ if ([paths count])
+ {
+ path = [paths objectAtIndex:0];
+ //HACK: Always attempt to create directory, ignore errors.
+ NSError *error = nil;
+
+ [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
+
+
+ result = std::string([path UTF8String]);
+ }
}
- [pool release];
return result;
}
-std::string* getSystemExecutableFolder()
+std::string getSystemExecutableFolder()
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSString *bundlePath = [[NSBundle mainBundle] executablePath];
- std::string *result = (new std::string([bundlePath UTF8String]));
- [pool release];
+ std::string result;
+ @autoreleasepool {
+ NSString *bundlePath = [[NSBundle mainBundle] executablePath];
+ result = std::string([bundlePath UTF8String]);
+ }
return result;
}
-std::string* getSystemResourceFolder()
+std::string getSystemResourceFolder()
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
- std::string *result = (new std::string([bundlePath UTF8String]));
- [pool release];
+ std::string result;
+ @autoreleasepool {
+ NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
+ result = std::string([bundlePath UTF8String]);
+ }
return result;
}
-std::string* getSystemCacheFolder()
+std::string getSystemCacheFolder()
{
return findSystemDirectory (NSCachesDirectory,
NSUserDomainMask);
}
-std::string* getSystemApplicationSupportFolder()
+std::string getSystemApplicationSupportFolder()
{
return findSystemDirectory (NSApplicationSupportDirectory,
NSUserDomainMask);
diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp
index 6de99dfbff..4b7363c8e5 100644
--- a/indra/llfilesystem/lldiskcache.cpp
+++ b/indra/llfilesystem/lldiskcache.cpp
@@ -35,7 +35,6 @@
#include "llassettype.h"
#include "lldir.h"
#include <boost/filesystem.hpp>
-#include <boost/range/iterator_range.hpp>
#include <chrono>
#include "lldiskcache.h"
@@ -100,19 +99,20 @@ void LLDiskCache::purge()
#endif
if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed())
{
- for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(cache_path, ec), {}))
+ boost::filesystem::directory_iterator iter(cache_path, ec);
+ while (iter != boost::filesystem::directory_iterator() && !ec.failed())
{
- if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed())
+ if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed())
{
- if (entry.path().string().find(mCacheFilenamePrefix) != std::string::npos)
+ if ((*iter).path().string().find(mCacheFilenamePrefix) != std::string::npos)
{
- uintmax_t file_size = boost::filesystem::file_size(entry, ec);
+ uintmax_t file_size = boost::filesystem::file_size(*iter, ec);
if (ec.failed())
{
continue;
}
- const std::string file_path = entry.path().string();
- const std::time_t file_time = boost::filesystem::last_write_time(entry, ec);
+ const std::string file_path = (*iter).path().string();
+ const std::time_t file_time = boost::filesystem::last_write_time(*iter, ec);
if (ec.failed())
{
continue;
@@ -121,6 +121,7 @@ void LLDiskCache::purge()
file_info.push_back(file_info_t(file_time, { file_size, file_path }));
}
}
+ iter.increment(ec);
}
}
@@ -348,19 +349,21 @@ void LLDiskCache::clearCache()
#endif
if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed())
{
- for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(cache_path, ec), {}))
+ boost::filesystem::directory_iterator iter(cache_path, ec);
+ while (iter != boost::filesystem::directory_iterator() && !ec.failed())
{
- if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed())
+ if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed())
{
- if (entry.path().string().find(mCacheFilenamePrefix) != std::string::npos)
+ if ((*iter).path().string().find(mCacheFilenamePrefix) != std::string::npos)
{
- boost::filesystem::remove(entry, ec);
+ boost::filesystem::remove(*iter, ec);
if (ec.failed())
{
- LL_WARNS() << "Failed to delete cache file " << entry << ": " << ec.message() << LL_ENDL;
+ LL_WARNS() << "Failed to delete cache file " << *iter << ": " << ec.message() << LL_ENDL;
}
}
}
+ iter.increment(ec);
}
}
}
@@ -379,20 +382,22 @@ void LLDiskCache::removeOldVFSFiles()
#endif
if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed())
{
- for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(cache_path, ec), {}))
+ boost::filesystem::directory_iterator iter(cache_path, ec);
+ while (iter != boost::filesystem::directory_iterator() && !ec.failed())
{
- if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed())
+ if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed())
{
- if ((entry.path().string().find(CACHE_FORMAT) != std::string::npos) ||
- (entry.path().string().find(DB_FORMAT) != std::string::npos))
+ if (((*iter).path().string().find(CACHE_FORMAT) != std::string::npos) ||
+ ((*iter).path().string().find(DB_FORMAT) != std::string::npos))
{
- boost::filesystem::remove(entry, ec);
+ boost::filesystem::remove(*iter, ec);
if (ec.failed())
{
- LL_WARNS() << "Failed to delete cache file " << entry << ": " << ec.message() << LL_ENDL;
+ LL_WARNS() << "Failed to delete cache file " << *iter << ": " << ec.message() << LL_ENDL;
}
}
}
+ iter.increment(ec);
}
}
}
@@ -418,19 +423,21 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir)
#endif
if (boost::filesystem::is_directory(dir_path, ec) && !ec.failed())
{
- for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(dir_path, ec), {}))
+ boost::filesystem::directory_iterator iter(dir_path, ec);
+ while (iter != boost::filesystem::directory_iterator() && !ec.failed())
{
- if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed())
+ if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed())
{
- if (entry.path().string().find(mCacheFilenamePrefix) != std::string::npos)
+ if ((*iter).path().string().find(mCacheFilenamePrefix) != std::string::npos)
{
- uintmax_t file_size = boost::filesystem::file_size(entry, ec);
+ uintmax_t file_size = boost::filesystem::file_size(*iter, ec);
if (!ec.failed())
{
total_file_size += file_size;
}
}
}
+ iter.increment(ec);
}
}