diff options
author | John Ankarström <john@ankarstrom.se> | 2023-01-23 01:05:37 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2023-01-23 01:06:58 +0100 |
commit | ab440290c6fd84ca1c9b7240ac9c90147d4660eb (patch) | |
tree | a96a66bdabb8e69cceade174c17faa6a2d768fba /c/ext.cpp | |
parent | de4e3d7654bf97cdae844d16c6ff5408698539ea (diff) | |
download | EpisodeBrowser-data.tar.gz |
Add Show In Explorer context menu item.data
Diffstat (limited to 'c/ext.cpp')
-rw-r--r-- | c/ext.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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; +} |