------------------------------------------------------------------------
| 247 | |
| 248 | //------------------------------------------------------------------------ |
| 249 | VST3::Optional<filesystem::path> resolveShellLink (const filesystem::path& p) |
| 250 | { |
| 251 | #if USE_FILESYSTEM |
| 252 | return {filesystem::read_symlink (p)}; |
| 253 | #else |
| 254 | #if USE_OLE |
| 255 | Ole::instance (); |
| 256 | |
| 257 | IShellLink* shellLink = nullptr; |
| 258 | if (!SUCCEEDED (CoCreateInstance (CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, |
| 259 | IID_IShellLink, reinterpret_cast<LPVOID*> (&shellLink)))) |
| 260 | return {}; |
| 261 | |
| 262 | IPersistFile* persistFile = nullptr; |
| 263 | if (!SUCCEEDED ( |
| 264 | shellLink->QueryInterface (IID_IPersistFile, reinterpret_cast<void**> (&persistFile)))) |
| 265 | return {}; |
| 266 | |
| 267 | if (!SUCCEEDED (persistFile->Load (p.wstring ().data (), STGM_READ))) |
| 268 | return {}; |
| 269 | |
| 270 | if (!SUCCEEDED (shellLink->Resolve (nullptr, MAKELONG (SLR_NO_UI, 500)))) |
| 271 | return {}; |
| 272 | |
| 273 | WCHAR resolvedPath[MAX_PATH]; |
| 274 | if (!SUCCEEDED (shellLink->GetPath (resolvedPath, MAX_PATH, nullptr, SLGP_SHORTPATH))) |
| 275 | return {}; |
| 276 | |
| 277 | std::wstring longPath; |
| 278 | longPath.resize (MAX_PATH); |
| 279 | auto numChars = |
| 280 | GetLongPathNameW (resolvedPath, const_cast<wchar_t*> (longPath.data ()), MAX_PATH); |
| 281 | if (!numChars) |
| 282 | return {}; |
| 283 | longPath.resize (numChars); |
| 284 | |
| 285 | persistFile->Release (); |
| 286 | shellLink->Release (); |
| 287 | |
| 288 | return {filesystem::path (longPath)}; |
| 289 | #else |
| 290 | // TODO for ARM |
| 291 | return {}; |
| 292 | #endif |
| 293 | #endif |
| 294 | } |
| 295 | |
| 296 | //------------------------------------------------------------------------ |
| 297 | void findFilesWithExt (const filesystem::path& path, const std::string& ext, |
no test coverage detected