| 355 | } |
| 356 | |
| 357 | HRESULT ExtensionLibrary::Load(std::optional<std::filesystem::path> tempDir) |
| 358 | { |
| 359 | using namespace std::filesystem; |
| 360 | |
| 361 | if (m_hModule != NULL) |
| 362 | return S_OK; |
| 363 | |
| 364 | if (auto hr = LoadDependencies(tempDir); FAILED(hr)) |
| 365 | { |
| 366 | Log::Error(L"Failed to load dependencies for extension library '{}'", m_strKeyword); |
| 367 | return hr; |
| 368 | } |
| 369 | |
| 370 | |
| 371 | WORD wArch = 0; |
| 372 | if (auto hr = SystemDetails::GetArchitecture(wArch); FAILED(hr)) |
| 373 | return hr; |
| 374 | |
| 375 | auto [dwMajor, dwMinor] = SystemDetails::GetOSVersion(); |
| 376 | |
| 377 | if (tempDir.has_value()) |
| 378 | { |
| 379 | if (exists(*tempDir)) |
| 380 | { |
| 381 | if (is_directory(*tempDir)) |
| 382 | { |
| 383 | Log::Debug(L"Using existing directory {} to load extension library", tempDir); |
| 384 | m_tempDir = std::move(*tempDir); |
| 385 | } |
| 386 | else |
| 387 | Log::Warn( |
| 388 | L"Specified temporary directory {} for extenstion library exists and is not a directory -> ignored", |
| 389 | tempDir); |
| 390 | } |
| 391 | else |
| 392 | { |
| 393 | Log::Debug(L"Creating temporary directory {} for extension library", tempDir); |
| 394 | std::error_code ec; |
| 395 | if (!create_directories(*tempDir, ec)) |
| 396 | { |
| 397 | Log::Error( |
| 398 | L"Specified temporary directory {} for extenstion library could not be created -> ignored", |
| 399 | tempDir); |
| 400 | } |
| 401 | else if (!ec) |
| 402 | { |
| 403 | m_tempDir = std::move(*tempDir); |
| 404 | m_bDeleteTemp = true; |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | if (m_tempDir.empty()) |
| 410 | { |
| 411 | m_tempDir = DefaultExtensionDirectory(); |
| 412 | } |
| 413 | |
| 414 | switch (wArch) |
no test coverage detected