| 2039 | //----------------------------------------------------------------------------- |
| 2040 | |
| 2041 | bool ModuleManager::registerModule( const char* pModulePath, const char* pModuleFile ) |
| 2042 | { |
| 2043 | // Sanity! |
| 2044 | AssertFatal( pModulePath != NULL, "Cannot scan module with NULL module path." ); |
| 2045 | AssertFatal( pModuleFile != NULL, "Cannot scan module with NULL module file." ); |
| 2046 | |
| 2047 | char formatBuffer[1024]; |
| 2048 | |
| 2049 | // Fetch module path trail character. |
| 2050 | char modulePathTrail = pModulePath[dStrlen(pModulePath) - 1]; |
| 2051 | |
| 2052 | // Format module file-path. |
| 2053 | dSprintf( formatBuffer, sizeof(formatBuffer), modulePathTrail == '/' ? "%s%s" : "%s/%s", pModulePath, pModuleFile ); |
| 2054 | |
| 2055 | // Read the module file. |
| 2056 | ModuleDefinition* pModuleDefinition = mTaml.read<ModuleDefinition>( formatBuffer ); |
| 2057 | |
| 2058 | // Did we read a module definition? |
| 2059 | if ( pModuleDefinition == NULL ) |
| 2060 | { |
| 2061 | // No, so warn. |
| 2062 | Con::warnf( "Module Manager: Failed to read module definition in file '%s'.", formatBuffer ); |
| 2063 | return false; |
| 2064 | } |
| 2065 | |
| 2066 | // Set the module manager. |
| 2067 | pModuleDefinition->setModuleManager( this ); |
| 2068 | |
| 2069 | // Set module definition path. |
| 2070 | pModuleDefinition->setModulePath( pModulePath ); |
| 2071 | |
| 2072 | // Set module file. |
| 2073 | pModuleDefinition->setModuleFile( pModuleFile ); |
| 2074 | |
| 2075 | // Set module file-path. |
| 2076 | pModuleDefinition->setModuleFilePath( formatBuffer ); |
| 2077 | |
| 2078 | // Fetch module Id. |
| 2079 | StringTableEntry moduleId = pModuleDefinition->getModuleId(); |
| 2080 | |
| 2081 | // Fetch module version Id. |
| 2082 | const U32 versionId = pModuleDefinition->getVersionId(); |
| 2083 | |
| 2084 | // Fetch module group. |
| 2085 | StringTableEntry moduleGroup = pModuleDefinition->getModuleGroup(); |
| 2086 | |
| 2087 | // Fetch module type. |
| 2088 | StringTableEntry moduleType = pModuleDefinition->getModuleType(); |
| 2089 | |
| 2090 | // Is the module enabled? |
| 2091 | if ( !pModuleDefinition->getEnabled() ) |
| 2092 | { |
| 2093 | // No, so warn. |
| 2094 | Con::warnf( "Module Manager: Found module: '%s' but it is disabled.", pModuleDefinition->getModuleFilePath() ); |
| 2095 | |
| 2096 | // Destroy module definition and finish. |
| 2097 | pModuleDefinition->deleteObject(); |
| 2098 | return false; |
no test coverage detected