MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / LoadAutoExtension

Method LoadAutoExtension

core/logic/ExtensionSys.cpp:542–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540}
541
542IExtension *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
581IExtension *CExtensionManager::FindExtensionByFile(const char *file)
582{

Callers 4

StartSourceModMethod · 0.80
DoGlobalPluginLoadsMethod · 0.80
LoadExtensionsMethod · 0.80
FindOrLoadDriverMethod · 0.80

Calls 8

GetFileExtensionMethod · 0.80
push_backMethod · 0.80
IsLoadedMethod · 0.80
IsPathFileMethod · 0.80
GetPathMethod · 0.80
LoadMethod · 0.45
LogErrorMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected