diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-06-17 23:21:54 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-09-21 09:46:32 +0200 |
| commit | a5f481aae19a6ef5b0cad48edaea5b58fc00ee05 (patch) | |
| tree | 50ab7bc8fe9a308b8dd1bea778884ac18d55d956 /src/lib | |
| parent | ff6c51d3aae0195f6612b01b7609342d3f53df26 (diff) | |
Move 'show in file manager' code to cross_*
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/cross.h | 1 | ||||
| -rw-r--r-- | src/lib/cross_linux.cc | 19 | ||||
| -rw-r--r-- | src/lib/cross_osx.cc | 9 | ||||
| -rw-r--r-- | src/lib/cross_windows.cc | 10 |
4 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/cross.h b/src/lib/cross.h index 25b3b3820..919113305 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -67,6 +67,7 @@ extern void unprivileged (); extern boost::filesystem::path config_path (); extern boost::filesystem::path directory_containing_executable (); extern boost::filesystem::path fix_long_path (boost::filesystem::path path); +extern bool show_in_file_manager (boost::filesystem::path dir, boost::filesystem::path select); namespace dcpomatic { std::string get_process_id (); } diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc index 65151791c..d142c416f 100644 --- a/src/lib/cross_linux.cc +++ b/src/lib/cross_linux.cc @@ -411,3 +411,22 @@ fix_long_path (boost::filesystem::path path) return path; } + +bool +show_in_file_manager (boost::filesystem::path dir, boost::filesystem::path) +{ + int r = system ("which nautilus"); + if (WEXITSTATUS(r) == 0) { + r = system (String::compose("nautilus \"%1\"", dir.string()).c_str()); + return static_cast<bool>(WEXITSTATUS(r)); + } else { + int r = system ("which konqueror"); + if (WEXITSTATUS(r) == 0) { + r = system (String::compose("konqueror \"%1\"", dir.string()).c_str()); + return static_cast<bool>(WEXITSTATUS(r)); + } + } + + return true; +} + diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index b9b7796a2..d0cb9f216 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -638,3 +638,12 @@ fix_long_path (boost::filesystem::path path) { return path; } + + +bool +show_in_file_manager (boost::filesystem::path, boost::filesystem::path select) +{ + int r = system (String::compose("open -R \"%1\"", select.string()).c_str()); + return static_cast<bool>(WEXITSTATUS(r)); +} + diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc index ac92aa7eb..f778a60e1 100644 --- a/src/lib/cross_windows.cc +++ b/src/lib/cross_windows.cc @@ -694,3 +694,13 @@ dcpomatic::get_process_id () return dcp::raw_convert<string>(GetCurrentProcessId()); } + +bool +show_in_file_manager (boost::filesystem::path, boost::filesystem::path select) +{ + std::wstringstream args; + args << "/select," << select; + auto const r = ShellExecute (0, L"open", L"explorer.exe", args.str().c_str(), 0, SW_SHOWDEFAULT); + return (reinterpret_cast<int64_t>(r) <= 32); +} + |
