| 1227 | //----------------------------------------------------------------------------- |
| 1228 | |
| 1229 | void 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; |
no test coverage detected