summaryrefslogtreecommitdiff
path: root/indra/llfilesystem
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2026-05-21 19:37:15 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2026-05-21 19:37:15 +0300
commit15d82beb6056fa16a1ea1cbf01c5d673a95e0267 (patch)
tree55af7639161926313434d9e4a8b9872369668d5d /indra/llfilesystem
parentff536adef0b74c20f55bd501ad593e4eef762082 (diff)
parent6d4c4c029ce43aa413266135829cd2bc00001890 (diff)
Merge branch 'main' into marchcat/slua-26.2
# Conflicts: # indra/llfilesystem/lldir.cpp # indra/llfilesystem/llfilesystem.cpp # indra/newview/llappviewer.cpp # indra/newview/lltexturecache.cpp # indra/newview/llvoiceclient.cpp # indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml
Diffstat (limited to 'indra/llfilesystem')
-rw-r--r--indra/llfilesystem/lldir.cpp56
-rw-r--r--indra/llfilesystem/lldir.h3
-rw-r--r--indra/llfilesystem/llfilesystem.cpp23
-rw-r--r--indra/llfilesystem/llfilesystem.h1
4 files changed, 80 insertions, 3 deletions
diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp
index 1a647362c5..756d09e69a 100644
--- a/indra/llfilesystem/lldir.cpp
+++ b/indra/llfilesystem/lldir.cpp
@@ -41,6 +41,7 @@
#include "lldiriterator.h"
#include "stringize.h"
#include "llstring.h"
+#include "llprocess.h"
#include <boost/bind.hpp>
#include <algorithm>
@@ -1087,6 +1088,61 @@ LLDir::SepOff LLDir::needSep(const std::string& path, const std::string& name) c
return SepOff(false, 0);
}
+void LLDir::openDir(const std::string& filepath)
+{
+ if (filepath.empty())
+ {
+ LL_WARNS() << "Cannot open file browser: filepath is empty" << LL_ENDL;
+ return;
+ }
+
+ // Extract directory path from full filepath
+ std::string dir_path = getDirName(filepath);
+
+ LLProcess::Params params;
+
+#if LL_WINDOWS
+ // Windows: Use explorer.exe with /select flag to highlight the file
+ std::string system_root = LLStringUtil::getenv("SystemRoot");
+ if (system_root.empty())
+ {
+ system_root = LLStringUtil::getenv("WINDIR");
+ }
+ if (system_root.empty())
+ {
+ LL_WARNS() << "Neither SystemRoot nor WINDIR environment variable is set" << LL_ENDL;
+ system_root = "C:\\Windows"; // Last resort fallback
+ }
+ params.executable = system_root + "\\explorer.exe";
+ params.args.add("/select,");
+ params.args.add(filepath);
+#elif LL_DARWIN
+ // macOS: Use 'open' command with -R flag to reveal in Finder
+ params.executable = "/usr/bin/open";
+ params.args.add("-R");
+ params.args.add(filepath);
+#elif LL_LINUX
+ // Linux: Use xdg-open to open the directory
+ // Note: Most file managers don't support file selection, so we open the directory
+ params.executable = "/usr/bin/xdg-open";
+ params.args.add(dir_path);
+#else
+ LL_WARNS() << "Platform not supported for file browser opening" << LL_ENDL;
+ return;
+#endif
+
+ params.autokill = false; // Don't kill the file browser when viewer exits
+
+ if (!LLProcess::create(params))
+ {
+ LL_WARNS() << "Failed to open file browser for: " << filepath << LL_ENDL;
+ }
+ else
+ {
+ LL_INFOS() << "Opened file browser for: " << filepath << LL_ENDL;
+ }
+}
+
void dir_exists_or_crash(const std::string &dir_name)
{
#if LL_WINDOWS
diff --git a/indra/llfilesystem/lldir.h b/indra/llfilesystem/lldir.h
index 8388816059..8742b7f937 100644
--- a/indra/llfilesystem/lldir.h
+++ b/indra/llfilesystem/lldir.h
@@ -194,6 +194,9 @@ class LLDir
virtual void dumpCurrentDirectories(LLError::ELevel level = LLError::LEVEL_DEBUG);
+ // Open the system file browser to reveal a file or directory
+ void openDir(const std::string& filepath);
+
// Utility routine
std::string buildSLOSCacheDir() const;
diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp
index 388cbc280f..dcebec494f 100644
--- a/indra/llfilesystem/llfilesystem.cpp
+++ b/indra/llfilesystem/llfilesystem.cpp
@@ -33,6 +33,7 @@
#include "llfilesystem.h"
#include "llfasttimer.h"
#include "lldiskcache.h"
+#include "boost/filesystem.hpp"
constexpr S32 LLFileSystem::READ = 0x00000001;
constexpr S32 LLFileSystem::WRITE = 0x00000002;
@@ -74,9 +75,12 @@ bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType fil
LL_PROFILE_ZONE_SCOPED;
const std::string filename = LLDiskCache::metaDataToFilepath(file_id, file_type);
- // not only test for existence but for the file to be not empty
- S64 size = LLFile::size(filename);
- return size > 0;
+ boost::system::error_code ec;
+ if (boost::filesystem::exists(filename, ec) && boost::filesystem::is_regular_file(filename, ec))
+ {
+ return boost::filesystem::file_size(filename, ec) > 0;
+ }
+ return false;
}
// static
@@ -108,6 +112,19 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp
return true;
}
+// static
+S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType file_type)
+{
+ const std::string filename = LLDiskCache::metaDataToFilepath(file_id, file_type);
+
+ boost::system::error_code ec;
+ if (boost::filesystem::exists(filename, ec) && boost::filesystem::is_regular_file(filename, ec))
+ {
+ return static_cast<S32>(boost::filesystem::file_size(filename, ec));
+ }
+ return 0;
+}
+
bool LLFileSystem::read(U8* buffer, S32 bytes)
{
bool success = false;
diff --git a/indra/llfilesystem/llfilesystem.h b/indra/llfilesystem/llfilesystem.h
index bc8b9216bd..d212a5d709 100644
--- a/indra/llfilesystem/llfilesystem.h
+++ b/indra/llfilesystem/llfilesystem.h
@@ -62,6 +62,7 @@ class LLFileSystem
void updateFileAccessTime();
static bool getExists(const LLUUID& file_id, const LLAssetType::EType file_type);
+ static S32 getFileSize(const LLUUID& file_id, const LLAssetType::EType file_type);
static bool removeFile(const LLUUID& file_id, const LLAssetType::EType file_type, int suppress_warning = 0);
static bool renameFile(const LLUUID& old_file_id, const LLAssetType::EType old_file_type,
const LLUUID& new_file_id, const LLAssetType::EType new_file_type);