summaryrefslogtreecommitdiff
path: root/indra/llfilesystem
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2025-11-19 21:05:46 +0200
committerAndrey Lihatskiy <alihatskiy@productengine.com>2025-11-19 21:05:46 +0200
commit093d969eb97ca03dbf4ae5cd3a3c784f58613a32 (patch)
tree916a65d49f2bfe6c12effba979bfa39417d6304a /indra/llfilesystem
parent7e09943d57ecf2d9b15249cbc19b4e2ec16f7bf3 (diff)
parentae659adab6f8d1adf0224d12fb3b379251eaa501 (diff)
Merge branch 'develop-linux' into marchcat/slua-linux
# Conflicts: # indra/newview/llfeaturemanager.cpp # indra/newview/llstartup.cpp
Diffstat (limited to 'indra/llfilesystem')
-rw-r--r--indra/llfilesystem/CMakeLists.txt11
-rw-r--r--indra/llfilesystem/lldir_win32.cpp4
-rw-r--r--indra/llfilesystem/lldiriterator.cpp2
-rw-r--r--indra/llfilesystem/lldiskcache.cpp12
-rw-r--r--indra/llfilesystem/tests/lldir_test.cpp31
5 files changed, 42 insertions, 18 deletions
diff --git a/indra/llfilesystem/CMakeLists.txt b/indra/llfilesystem/CMakeLists.txt
index 9f24f75eab..a552e4bdbc 100644
--- a/indra/llfilesystem/CMakeLists.txt
+++ b/indra/llfilesystem/CMakeLists.txt
@@ -28,6 +28,12 @@ if (DARWIN)
LIST(APPEND llfilesystem_SOURCE_FILES lldir_utils_objc.h)
LIST(APPEND llfilesystem_SOURCE_FILES lldir_mac.cpp)
LIST(APPEND llfilesystem_HEADER_FILES lldir_mac.h)
+
+ set_source_files_properties(
+ lldir_utils_objc.mm
+ PROPERTIES
+ SKIP_PRECOMPILE_HEADERS TRUE
+ )
endif (DARWIN)
if (LINUX)
@@ -52,10 +58,15 @@ list(APPEND llfilesystem_SOURCE_FILES ${llfilesystem_HEADER_FILES})
add_library (llfilesystem ${llfilesystem_SOURCE_FILES})
target_link_libraries(llfilesystem
+ llmath
llcommon
)
target_include_directories( llfilesystem INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+if (USE_PRECOMPILED_HEADERS)
+ target_precompile_headers(llfilesystem REUSE_FROM llprecompiled)
+endif ()
+
# Add tests
if (LL_TESTS)
include(LLAddBuildTest)
diff --git a/indra/llfilesystem/lldir_win32.cpp b/indra/llfilesystem/lldir_win32.cpp
index 58c080c982..9624b1197f 100644
--- a/indra/llfilesystem/lldir_win32.cpp
+++ b/indra/llfilesystem/lldir_win32.cpp
@@ -52,7 +52,7 @@ namespace
// This is called so early that we can't count on static objects being
// properly constructed yet, so declare a pointer instead of an instance.
- std::ofstream* prelogf = nullptr;
+ llofstream* prelogf = nullptr;
void prelog(const std::string& message)
{
@@ -208,7 +208,7 @@ LLDir_Win32::LLDir_Win32()
{
// successfully created logdir, plunk a log file there
std::string logfilename(add(mOSUserDir, "lldir.log"));
- std::ofstream logfile(logfilename.c_str());
+ llofstream logfile(logfilename.c_str());
if (! logfile.is_open())
{
report(std::cerr);
diff --git a/indra/llfilesystem/lldiriterator.cpp b/indra/llfilesystem/lldiriterator.cpp
index e8c37389d2..b736a577bd 100644
--- a/indra/llfilesystem/lldiriterator.cpp
+++ b/indra/llfilesystem/lldiriterator.cpp
@@ -24,6 +24,8 @@
* $/LicenseInfo$
*/
+#include "linden_common.h"
+
#include "lldiriterator.h"
#include "fix_macros.h"
diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp
index e971e1885a..c75df16b7d 100644
--- a/indra/llfilesystem/lldiskcache.cpp
+++ b/indra/llfilesystem/lldiskcache.cpp
@@ -112,6 +112,10 @@ void LLDiskCache::purge()
boost::filesystem::directory_iterator iter(cache_path, ec);
while (iter != boost::filesystem::directory_iterator() && !ec.failed())
{
+ if(!LLApp::isRunning())
+ {
+ return;
+ }
if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed())
{
if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos)
@@ -150,6 +154,10 @@ void LLDiskCache::purge()
uintmax_t file_size_total = 0;
for (file_info_t& entry : file_info)
{
+ if (!LLApp::isRunning())
+ {
+ return;
+ }
file_size_total += entry.second.first;
bool should_remove = file_size_total > mMaxSizeBytes;
@@ -176,6 +184,10 @@ void LLDiskCache::purge()
// Logging thousands of file results can take hundreds of milliseconds
for (size_t i = 0; i < file_info.size(); ++i)
{
+ if (!LLApp::isRunning())
+ {
+ return;
+ }
const file_info_t& entry = file_info[i];
const bool removed = file_removed[i];
const std::string action = removed ? "DELETE:" : "KEEP:";
diff --git a/indra/llfilesystem/tests/lldir_test.cpp b/indra/llfilesystem/tests/lldir_test.cpp
index d7d57fa86f..4fa5769f65 100644
--- a/indra/llfilesystem/tests/lldir_test.cpp
+++ b/indra/llfilesystem/tests/lldir_test.cpp
@@ -27,12 +27,14 @@
#include "linden_common.h"
+#include <filesystem>
#include "llstring.h"
#include "tests/StringVec.h"
#include "../lldir.h"
#include "../lldiriterator.h"
#include "../test/lltut.h"
+#include "../test/namedtempfile.h"
#include "stringize.h"
#include <boost/assign/list_of.hpp>
@@ -425,23 +427,19 @@ namespace tut
return path;
}
- std::string makeTestDir( const std::string& dirbase )
+ std::string makeTestDir( )
{
- int counter;
- std::string uniqueDir;
- bool foundUnused;
- std::string delim = gDirUtilp->getDirDelimiter();
+ auto p = NamedTempFile::temp_path();
+ std::filesystem::create_directories(p.native());
- for (counter=0, foundUnused=false; !foundUnused; counter++ )
- {
- char counterStr[3];
- snprintf(counterStr, sizeof(counterStr), "%02d", counter);
- uniqueDir = dirbase + counterStr;
- foundUnused = ! ( LLFile::isdir(uniqueDir) || LLFile::isfile(uniqueDir) );
- }
- ensure("test directory '" + uniqueDir + "' creation failed", !LLFile::mkdir(uniqueDir));
+ std::string ret = p.string();
- return uniqueDir + delim; // HACK - apparently, the trailing delimiter is needed...
+ // There's an implicit assumtion all over this code that the returned path ends with "/" (or "\")
+
+ if(ret.size() >= 1 && ret[ ret.size()-1 ] != std::filesystem::path::preferred_separator )
+ ret += std::filesystem::path::preferred_separator;
+
+ return ret;
}
static const char* DirScanFilename[5] = { "file1.abc", "file2.abc", "file1.xyz", "file2.xyz", "file1.mno" };
@@ -497,8 +495,9 @@ namespace tut
// Create the same 5 file names of the two directories
- std::string dir1 = makeTestDir(dirTemp + "LLDirIterator");
- std::string dir2 = makeTestDir(dirTemp + "LLDirIterator");
+ std::string dir1 = makeTestDir();
+ std::string dir2 = makeTestDir();
+
std::string dir1files[5];
std::string dir2files[5];
for (int i=0; i<5; i++)