diff options
| author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2026-05-21 19:37:15 +0300 |
|---|---|---|
| committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2026-05-21 19:37:15 +0300 |
| commit | 15d82beb6056fa16a1ea1cbf01c5d673a95e0267 (patch) | |
| tree | 55af7639161926313434d9e4a8b9872369668d5d /indra/llfilesystem/lldir.cpp | |
| parent | ff536adef0b74c20f55bd501ad593e4eef762082 (diff) | |
| parent | 6d4c4c029ce43aa413266135829cd2bc00001890 (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/lldir.cpp')
| -rw-r--r-- | indra/llfilesystem/lldir.cpp | 56 |
1 files changed, 56 insertions, 0 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 |
