summaryrefslogtreecommitdiff
path: root/indra/llfilesystem/lldiskcache.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2023-04-07 00:20:59 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2023-04-07 00:20:59 +0300
commitf1095d78315818642e62b7f4af9984557e176b5d (patch)
tree3606970e28e1101befbc7b42ccd6033cfd839e7b /indra/llfilesystem/lldiskcache.cpp
parent4042ed9701fcfa42c03fc285a757aa348f800e33 (diff)
parentc7053a6928fd5eafdc935453742e92951ae4e0c1 (diff)
Merge branch 'main' into marchcat/main-contrib-merge
# Conflicts: # indra/cmake/CMakeLists.txt # indra/llcommon/llsdserialize.cpp # indra/llcommon/llsdserialize.h # indra/llcommon/tests/llleap_test.cpp # indra/newview/llfilepicker.h # indra/newview/llfilepicker_mac.h # indra/newview/llfilepicker_mac.mm # indra/newview/skins/default/xui/en/strings.xml
Diffstat (limited to 'indra/llfilesystem/lldiskcache.cpp')
-rw-r--r--indra/llfilesystem/lldiskcache.cpp51
1 files changed, 29 insertions, 22 deletions
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);
}
}