Ejemplo n.º 1
0
IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength)
{
	/* Remove platform extension if it's there. Compat hack. */
	const char *ext = libsys->GetFileExtension(file);
	if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
	{
		char path2[PLATFORM_MAX_PATH];
		smcore.Format(path2, sizeof(path2), "%s", file);
		path2[strlen(file) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
		return LoadExtension(path2, error, maxlength);
	}

	IExtension *pAlready;
	if ((pAlready=FindExtensionByFile(file)) != NULL)
	{
		return pAlready;
	}

	CExtension *pExt = new CLocalExtension(file);

	if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
	{
		pExt->Unload();
		delete pExt;
		return NULL;
	}

	/* :TODO: do QueryRunning check if the map is loaded */

	m_Libs.push_back(pExt);

	return pExt;
}
Ejemplo n.º 2
0
IExtension *CExtensionManager::LoadAutoExtension(const char *path)
{
	/* Remove platform extension if it's there. Compat hack. */
	const char *ext = libsys->GetFileExtension(path);
	if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
	{
		char path2[PLATFORM_MAX_PATH];
		smcore.Format(path2, sizeof(path2), "%s", path);
		path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
		return LoadAutoExtension(path2);
	}

	IExtension *pAlready;
	if ((pAlready=FindExtensionByFile(path)) != NULL)
	{
		return pAlready;
	}

	char error[256];
	CExtension *p = new CLocalExtension(path);

	/* We put us in the list beforehand so extensions that check for each other
	 * won't recursively load each other.
	 */
	m_Libs.push_back(p);

	if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
	{
		smcore.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
		p->SetError(error);
	}

	return p;
}
Ejemplo n.º 3
0
IExtension *CExtensionManager::LoadExternal(IExtensionInterface *pInterface,
											const char *filepath,
											const char *filename,
											char *error,
											size_t maxlength)
{
	IExtension *pAlready;
	if ((pAlready=FindExtensionByFile(filename)) != NULL)
	{
		return pAlready;
	}

	CExtension *pExt = new CRemoteExtension(pInterface, filename, filepath);

	if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
	{
		pExt->Unload();
		delete pExt;
		return NULL;
	}

	m_Libs.push_back(pExt);

	return pExt;
}
Ejemplo n.º 4
0
IExtension *CExtensionManager::LoadAutoExtension(const char *path)
{
    if (!strstr(path, "." PLATFORM_LIB_EXT))
    {
        char newpath[PLATFORM_MAX_PATH];
        g_LibSys.PathFormat(newpath, sizeof(newpath), "%s.%s", path, PLATFORM_LIB_EXT);
        return LoadAutoExtension(newpath);
    }

    IExtension *pAlready;
    if ((pAlready=FindExtensionByFile(path)) != NULL)
    {
        return pAlready;
    }

    char error[256];
    CExtension *p = new CLocalExtension(path);

    /* We put us in the list beforehand so extensions that check for each other
     * won't recursively load each other.
     */
    m_Libs.push_back(p);

    if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
    {
        g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
        p->SetError(error);
    }

    return p;
}
Ejemplo n.º 5
0
IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength)
{
    IExtension *pAlready;
    if ((pAlready=FindExtensionByFile(file)) != NULL)
    {
        return pAlready;
    }

    CExtension *pExt = new CLocalExtension(file);

    if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
    {
        pExt->Unload();
        delete pExt;
        return NULL;
    }

    /* :TODO: do QueryRunning check if the map is loaded */

    m_Libs.push_back(pExt);

    return pExt;
}