本文整理汇总了C++中CExtension::GetFilename方法的典型用法代码示例。如果您正苦于以下问题:C++ CExtension::GetFilename方法的具体用法?C++ CExtension::GetFilename怎么用?C++ CExtension::GetFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CExtension
的用法示例。
在下文中一共展示了CExtension::GetFilename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindExtensionByFile
IExtension *CExtensionManager::FindExtensionByFile(const char *file)
{
List<CExtension *>::iterator iter;
CExtension *pExt;
/* Chomp off the path */
char lookup[PLATFORM_MAX_PATH];
g_LibSys.GetFileFromPath(lookup, sizeof(lookup), file);
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
{
pExt = (*iter);
char short_file[PLATFORM_MAX_PATH];
g_LibSys.GetFileFromPath(short_file, sizeof(short_file), pExt->GetFilename());
if (strcmp(lookup, short_file) == 0)
{
return pExt;
}
}
/* If we got no results, test if there was a platform extension.
* If not, add one.
*/
if (!strstr(file, "." PLATFORM_LIB_EXT))
{
char path[PLATFORM_MAX_PATH];
UTIL_Format(path, sizeof(path), "%s.%s", file, PLATFORM_LIB_EXT);
return FindExtensionByFile(path);
}
return NULL;
}
示例2: OnRootConsoleCommand
void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
{
int argcount = smcore.Argc(command);
if (argcount >= 3)
{
const char *cmd = smcore.Arg(command, 2);
if (strcmp(cmd, "list") == 0)
{
List<CExtension *>::iterator iter;
CExtension *pExt;
unsigned int num = 1;
switch (m_Libs.size())
{
case 1:
{
rootmenu->ConsolePrint("[SM] Displaying 1 extension:");
break;
}
case 0:
{
rootmenu->ConsolePrint("[SM] No extensions are loaded.");
break;
}
default:
{
rootmenu->ConsolePrint("[SM] Displaying %d extensions:", m_Libs.size());
break;
}
}
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++,num++)
{
pExt = (*iter);
if (pExt->IsLoaded())
{
char error[255];
if (!pExt->IsRunning(error, sizeof(error)))
{
rootmenu->ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), error);
}
else
{
IExtensionInterface *pAPI = pExt->GetAPI();
const char *name = pAPI->GetExtensionName();
const char *version = pAPI->GetExtensionVerString();
const char *descr = pAPI->GetExtensionDescription();
rootmenu->ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr);
}
} else {
rootmenu->ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str());
}
}
return;
}
else if (strcmp(cmd, "load") == 0)
{
if (argcount < 4)
{
rootmenu->ConsolePrint("[SM] Usage: sm exts load <file>");
return;
}
const char *filename = smcore.Arg(command, 3);
char path[PLATFORM_MAX_PATH];
char error[256];
smcore.Format(path, sizeof(path), "%s%s%s", filename, !strstr(filename, ".ext") ? ".ext" : "",
!strstr(filename, "." PLATFORM_LIB_EXT) ? "." PLATFORM_LIB_EXT : "");
if (FindExtensionByFile(path) != NULL)
{
rootmenu->ConsolePrint("[SM] Extension %s is already loaded.", path);
return;
}
if (LoadExtension(path, error, sizeof(error)))
{
rootmenu->ConsolePrint("[SM] Loaded extension %s successfully.", path);
} else
{
rootmenu->ConsolePrint("[SM] Extension %s failed to load: %s", path, error);
}
return;
}
else if (strcmp(cmd, "info") == 0)
{
if (argcount < 4)
{
rootmenu->ConsolePrint("[SM] Usage: sm exts info <#>");
return;
}
const char *sId = smcore.Arg(command, 3);
unsigned int id = atoi(sId);
if (id <= 0)
{
rootmenu->ConsolePrint("[SM] Usage: sm exts info <#>");
return;
}
//.........这里部分代码省略.........
示例3: Dump
void HandleSystem::Dump(HANDLE_REPORTER rep)
{
unsigned int total_size = 0;
rep("%-10.10s\t%-20.20s\t%-20.20s\t%-10.10s", "Handle", "Owner", "Type", "Memory");
rep("--------------------------------------------------------------------------");
for (unsigned int i = 1; i <= m_HandleTail; i++)
{
if (m_Handles[i].set != HandleSet_Used)
{
continue;
}
/* Get the index */
unsigned int index = (m_Handles[i].serial << 16) | i;
/* Determine the owner */
const char *owner = "UNKNOWN";
if (m_Handles[i].owner)
{
IdentityToken_t *pOwner = m_Handles[i].owner;
if (pOwner == g_pCoreIdent)
{
owner = "CORE";
}
else if (pOwner == g_PluginSys.GetIdentity())
{
owner = "PLUGINSYS";
}
else
{
CExtension *ext = g_Extensions.GetExtensionFromIdent(pOwner);
if (ext)
{
owner = ext->GetFilename();
}
else
{
CPlugin *pPlugin = g_PluginSys.GetPluginFromIdentity(pOwner);
if (pPlugin)
{
owner = pPlugin->GetFilename();
}
}
}
}
else
{
owner = "NONE";
}
const char *type = "ANON";
QHandleType *pType = &m_Types[m_Handles[i].type];
unsigned int size = 0;
if (pType->nameIdx != -1)
{
type = m_strtab->GetString(pType->nameIdx);
}
if (pType->dispatch->GetDispatchVersion() < HANDLESYS_MEMUSAGE_MIN_VERSION
|| !pType->dispatch->GetHandleApproxSize(m_Handles[i].type, m_Handles[i].object, &size))
{
rep("0x%08x\t%-20.20s\t%-20.20s\t%-10.10s", index, owner, type, "-1");
}
else
{
char buffer[32];
UTIL_Format(buffer, sizeof(buffer), "%d", size);
rep("0x%08x\t%-20.20s\t%-20.20s\t%-10.10s", index, owner, type, buffer);
total_size += size;
}
}
rep("-- Approximately %d bytes of memory are in use by Handles.\n", total_size);
}