MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / addPathExpando

Function addPathExpando

engine/source/console/console.cc:1229–1292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1227//-----------------------------------------------------------------------------
1228
1229void addPathExpando( const char* pExpandoName, const char* pPath )
1230{
1231 // Sanity!
1232 AssertFatal( pExpandoName != NULL, "Expando name cannot be NULL." );
1233 AssertFatal( pPath != NULL, "Expando path cannot be NULL." );
1234
1235 // Fetch expando name.
1236 StringTableEntry expandoName = StringTable->insert( pExpandoName );
1237
1238 // Fetch the length of the path.
1239 S32 pathLength = dStrlen(pPath);
1240
1241 char pathBuffer[1024];
1242
1243 // Sanity!
1244 if ( pathLength == 0 || pathLength >= sizeof(pathBuffer) )
1245 {
1246 Con::warnf( "Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath );
1247 return;
1248 }
1249
1250 // Strip repeat slashes.
1251 if ( !Con::stripRepeatSlashes(pathBuffer, pPath, sizeof(pathBuffer) ) )
1252 {
1253 Con::warnf( "Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath );
1254 return;
1255 }
1256
1257 // Fetch new path length.
1258 pathLength = dStrlen(pathBuffer);
1259
1260 // Sanity!
1261 if ( pathLength == 0 )
1262 {
1263 Con::warnf( "Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath );
1264 return;
1265 }
1266
1267 // Remove any terminating slash.
1268 if (pathBuffer[pathLength-1] == '/')
1269 pathBuffer[pathLength-1] = 0;
1270
1271 // Fetch expanded path.
1272 StringTableEntry expandedPath = StringTable->insert( pathBuffer );
1273
1274 // Info.
1275 #if defined(TORQUE_DEBUG)
1276 Con::printf("Adding path expando of '%s' as '%s'.", expandoName, expandedPath );
1277 #endif
1278
1279 // Find any existing path expando.
1280 typePathExpandoMap::iterator expandoItr = PathExpandos.find( pExpandoName );
1281
1282 // Does the expando exist?
1283 if( expandoItr != PathExpandos.end() )
1284 {
1285 // Yes, so modify the path.
1286 expandoItr->value = expandedPath;

Callers 3

loadModuleGroupMethod · 0.85
loadModuleExplicitMethod · 0.85

Calls 7

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

Tested by

no test coverage detected