MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / addPathExpando

Function addPathExpando

Engine/source/console/console.cpp:1972–2035  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1970//-----------------------------------------------------------------------------
1971
1972void addPathExpando(const char* pExpandoName, const char* pPath)
1973{
1974 // Sanity!
1975 AssertFatal(pExpandoName != NULL, "Expando name cannot be NULL.");
1976 AssertFatal(pPath != NULL, "Expando path cannot be NULL.");
1977
1978 // Fetch expando name.
1979 StringTableEntry expandoName = StringTable->insert(pExpandoName);
1980
1981 // Fetch the length of the path.
1982 S32 pathLength = dStrlen(pPath);
1983
1984 char pathBuffer[1024];
1985
1986 // Sanity!
1987 if (pathLength == 0 || pathLength >= sizeof(pathBuffer))
1988 {
1989 Con::warnf("Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath);
1990 return;
1991 }
1992
1993 // Strip repeat slashes.
1994 if (!Con::stripRepeatSlashes(pathBuffer, pPath, sizeof(pathBuffer)))
1995 {
1996 Con::warnf("Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath);
1997 return;
1998 }
1999
2000 // Fetch new path length.
2001 pathLength = dStrlen(pathBuffer);
2002
2003 // Sanity!
2004 if (pathLength == 0)
2005 {
2006 Con::warnf("Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath);
2007 return;
2008 }
2009
2010 // Remove any terminating slash.
2011 if (pathBuffer[pathLength - 1] == '/')
2012 pathBuffer[pathLength - 1] = 0;
2013
2014 // Fetch expanded path.
2015 StringTableEntry expandedPath = StringTable->insert(pathBuffer);
2016
2017 // Info.
2018#if defined(TORQUE_DEBUG)
2019 Con::printf("Adding path expando of '%s' as '%s'.", expandoName, expandedPath);
2020#endif
2021
2022 // Find any existing path expando.
2023 typePathExpandoMap::iterator expandoItr = PathExpandos.find(pExpandoName);
2024
2025 // Does the expando exist?
2026 if (expandoItr != PathExpandos.end())
2027 {
2028 // Yes, so modify the path.
2029 expandoItr->value = expandedPath;

Callers 2

loadModuleGroupMethod · 0.85
loadModuleExplicitMethod · 0.85

Calls 7

stripRepeatSlashesFunction · 0.85
printfFunction · 0.85
warnfFunction · 0.70
dStrlenFunction · 0.50
insertMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected