diff options
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; +} |