| 540 | } |
| 541 | |
| 542 | IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOnMissing) |
| 543 | { |
| 544 | /* Remove platform extension if it's there. Compat hack. */ |
| 545 | const char *ext = libsys->GetFileExtension(path); |
| 546 | if (strcmp(ext, PLATFORM_LIB_EXT) == 0) |
| 547 | { |
| 548 | char path2[PLATFORM_MAX_PATH]; |
| 549 | ke::SafeStrcpy(path2, sizeof(path2), path); |
| 550 | path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0'; |
| 551 | return LoadAutoExtension(path2, bErrorOnMissing); |
| 552 | } |
| 553 | |
| 554 | IExtension *pAlready; |
| 555 | if ((pAlready=FindExtensionByFile(path)) != NULL) |
| 556 | { |
| 557 | return pAlready; |
| 558 | } |
| 559 | |
| 560 | char error[256]; |
| 561 | CExtension *p = new CLocalExtension(path, bErrorOnMissing); |
| 562 | |
| 563 | /* We put us in the list beforehand so extensions that check for each other |
| 564 | * won't recursively load each other. |
| 565 | */ |
| 566 | m_Libs.push_back(p); |
| 567 | |
| 568 | if (!p->Load(error, sizeof(error)) || !p->IsLoaded()) |
| 569 | { |
| 570 | if (bErrorOnMissing || libsys->IsPathFile(p->GetPath())) |
| 571 | { |
| 572 | logger->LogError("[SM] Unable to load extension \"%s\": %s", path, error); |
| 573 | } |
| 574 | |
| 575 | p->SetError(error); |
| 576 | } |
| 577 | |
| 578 | return p; |
| 579 | } |
| 580 | |
| 581 | IExtension *CExtensionManager::FindExtensionByFile(const char *file) |
| 582 | { |
no test coverage detected