| 632 | } |
| 633 | |
| 634 | IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength) |
| 635 | { |
| 636 | if (strstr(file, "..") != NULL) |
| 637 | { |
| 638 | ke::SafeStrcpy(error, maxlength, "Cannot load extensions outside the \"extensions\" folder."); |
| 639 | return NULL; |
| 640 | } |
| 641 | |
| 642 | /* Remove platform extension if it's there. Compat hack. */ |
| 643 | const char *ext = libsys->GetFileExtension(file); |
| 644 | if (ext && strcmp(ext, PLATFORM_LIB_EXT) == 0) |
| 645 | { |
| 646 | char path2[PLATFORM_MAX_PATH]; |
| 647 | ke::SafeStrcpy(path2, sizeof(path2), file); |
| 648 | path2[strlen(file) - strlen(PLATFORM_LIB_EXT) - 1] = '\0'; |
| 649 | return LoadExtension(path2, error, maxlength); |
| 650 | } |
| 651 | |
| 652 | IExtension *pAlready; |
| 653 | if ((pAlready=FindExtensionByFile(file)) != NULL) |
| 654 | { |
| 655 | return pAlready; |
| 656 | } |
| 657 | |
| 658 | CExtension *pExt = new CLocalExtension(file); |
| 659 | |
| 660 | if (!pExt->Load(error, maxlength) || !pExt->IsLoaded()) |
| 661 | { |
| 662 | pExt->Unload(); |
| 663 | delete pExt; |
| 664 | return NULL; |
| 665 | } |
| 666 | |
| 667 | /* :TODO: do QueryRunning check if the map is loaded */ |
| 668 | |
| 669 | m_Libs.push_back(pExt); |
| 670 | |
| 671 | return pExt; |
| 672 | } |
| 673 | |
| 674 | void CExtensionManager::BindDependency(IExtension *pRequester, IfaceInfo *pInfo) |
| 675 | { |
nothing calls this directly
no test coverage detected