Open Directory selects the file in the file manager

Showing a spritesheet, sound, library (or Explore XML Location's document)
opens its folder with the file selected: explorer /select on Windows, the
freedesktop FileManager1 ShowItems call on Linux (Nautilus, Dolphin, Nemo,
Caja, Thunar...), falling back to opening the folder. Paths go to the shell
single-quoted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-21 01:18:05 -04:00
1 parent a6f9b425e8
commit d77b2bae71
3 files changed
+48 -5

No files matched your search

+3 -1
View File
@@ -342,13 +342,15 @@ namespace anm2ed::imgui
return path::backslash_replace(path::make_relative(path::backslash_handle(path), document.directory_get()));
}
// Shows a resource's file selected in the file manager (or the nearest folder there is, when it's missing).
void directory_open(Dialog& dialog, Document& document, const std::filesystem::path& path)
{
if (path.empty()) return;
std::error_code ec{};
auto absolutePath = std::filesystem::weakly_canonical(document.directory_get() / path, ec);
if (ec) absolutePath = document.directory_get() / path;
auto target = std::filesystem::is_directory(absolutePath) ? absolutePath
auto target = std::filesystem::is_regular_file(absolutePath, ec) || std::filesystem::is_directory(absolutePath, ec)
? absolutePath
: std::filesystem::is_directory(absolutePath.parent_path()) ? absolutePath.parent_path()
: document.directory_get();
dialog.file_explorer_open(target);