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

Method renameModule

Engine/source/module/moduleManager.cpp:1346–1442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1344//-----------------------------------------------------------------------------
1345
1346bool ModuleManager::renameModule(ModuleDefinition* pSourceModuleDefinition, const char* pNewModuleName)
1347{
1348 // Sanity!
1349 AssertFatal(pSourceModuleDefinition != NULL, "Cannot copy module using a NULL source module definition.");
1350 AssertFatal(pNewModuleName != NULL, "Cannot rename a module using a NULL module name.");
1351
1352 // Fetch the source module Id.
1353 StringTableEntry sourceModuleId = pSourceModuleDefinition->getModuleId();
1354
1355 // Is the source module definition registered with this module manager?
1356 if (pSourceModuleDefinition->getModuleManager() != this)
1357 {
1358 // No, so warn.
1359 Con::warnf("Module Manager: Cannot rename module Id '%s' as it is not registered with this module manager.", sourceModuleId);
1360 return StringTable->EmptyString();
1361 }
1362
1363 TamlModuleIdUpdateVisitor moduleIdUpdateVisitor;
1364 moduleIdUpdateVisitor.setModuleIdFrom(sourceModuleId);
1365 moduleIdUpdateVisitor.setModuleIdTo(pNewModuleName);
1366
1367 Vector<Platform::FileInfo> files;
1368
1369 const char* pExtension = (const char*)"Taml";
1370 const U32 extensionLength = dStrlen(pExtension);
1371
1372 Vector<StringTableEntry> directories;
1373
1374 StringTableEntry modulePath = pSourceModuleDefinition->getModulePath();
1375
1376 // Find directories.
1377 if (!Platform::dumpDirectories(modulePath, directories, -1))
1378 {
1379 // Warn.
1380 Con::warnf("Module Manager: Cannot rename module Id '%s' in directory '%s' as sub-folder scanning/renaming failed.",
1381 sourceModuleId, modulePath);
1382 return false;
1383 }
1384
1385 // Iterate directories.
1386 for (Vector<StringTableEntry>::iterator basePathItr = directories.begin(); basePathItr != directories.end(); ++basePathItr)
1387 {
1388 // Fetch base path.
1389 StringTableEntry basePath = *basePathItr;
1390
1391 // Find files.
1392 files.clear();
1393 if (!Platform::dumpPath(basePath, files, 0))
1394 {
1395 // Warn.
1396 Con::warnf("Module Manager: Cannot rename module Id '%s' in directory '%s' as sub-folder scanning/renaming failed.",
1397 sourceModuleId, modulePath);
1398 return false;
1399 }
1400
1401 // Iterate files.
1402 for (Vector<Platform::FileInfo>::iterator fileItr = files.begin(); fileItr != files.end(); ++fileItr)
1403 {

Callers 1

Calls 15

dStricmpFunction · 0.85
dSprintfFunction · 0.85
printfFunction · 0.85
getModuleIdMethod · 0.80
getModuleManagerMethod · 0.80
EmptyStringMethod · 0.80
setModuleIdFromMethod · 0.80
setModuleIdToMethod · 0.80
getModulePathMethod · 0.80
warnfFunction · 0.50
dStrlenFunction · 0.50
beginMethod · 0.45

Tested by

no test coverage detected