aboutsummaryrefslogtreecommitdiff
path: root/c/ext.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2023-01-23 01:05:37 +0100
committerJohn Ankarström <john@ankarstrom.se>2023-01-23 01:06:58 +0100
commitab440290c6fd84ca1c9b7240ac9c90147d4660eb (patch)
treea96a66bdabb8e69cceade174c17faa6a2d768fba /c/ext.cpp
parentde4e3d7654bf97cdae844d16c6ff5408698539ea (diff)
downloadEpisodeBrowser-ab440290c6fd84ca1c9b7240ac9c90147d4660eb.tar.gz
Add Show In Explorer context menu item.data
Diffstat (limited to 'c/ext.cpp')
-rw-r--r--c/ext.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/c/ext.cpp b/c/ext.cpp
index 3c9542b..33218d2 100644
--- a/c/ext.cpp
+++ b/c/ext.cpp
@@ -1,4 +1,5 @@
#include <ctype.h>
+#include <shlobj.h>
#include <string>
#include <string_view>
@@ -119,3 +120,25 @@ bool OpenLocally(CfgA& cfg, const ElvDataA& e)
} else
return false;
}
+
+bool ShowInExplorer(CfgA& cfg, const ElvDataA& e)
+{
+ wchar_t file[MAX_PATH];
+ if (FindMatchingFile(file, cfg.root, e.siEp)) {
+ /* ILCreateFromPath does not support forward slashes. */
+ for (wchar_t *f = file; *f; f++)
+ if (*f == L'/')
+ *f = L'\\';
+
+ if (ITEMIDLIST* idl = ILCreateFromPath(file)) {
+ HRESULT r = SHOpenFolderAndSelectItems(idl, 0, 0, 0);
+ ILFree(idl);
+ if (FAILED(r)) {
+ SetLastError(r);
+ throw Err(WINDOWS, L"File "s + file + L" could not be shown in Explorer");
+ }
+ }
+ return true;
+ } else
+ return false;
+}