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

Function addPathExpando

Engine/source/console/console.cpp:1892–1955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1890//-----------------------------------------------------------------------------
1891
1892void addPathExpando(const char* pExpandoName, const char* pPath)
1893{
1894 // Sanity!
1895 AssertFatal(pExpandoName != NULL, "Expando name cannot be NULL.");
1896 AssertFatal(pPath != NULL, "Expando path cannot be NULL.");
1897
1898 // Fetch expando name.
1899 StringTableEntry expandoName = StringTable->insert(pExpandoName);
1900
1901 // Fetch the length of the path.
1902 S32 pathLength = dStrlen(pPath);
1903
1904 char pathBuffer[1024];
1905
1906 // Sanity!
1907 if (pathLength == 0 || pathLength >= sizeof(pathBuffer))
1908 {
1909 Con::warnf("Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath);
1910 return;
1911 }
1912
1913 // Strip repeat slashes.
1914 if (!Con::stripRepeatSlashes(pathBuffer, pPath, sizeof(pathBuffer)))
1915 {
1916 Con::warnf("Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath);
1917 return;
1918 }
1919
1920 // Fetch new path length.
1921 pathLength = dStrlen(pathBuffer);
1922
1923 // Sanity!
1924 if (pathLength == 0)
1925 {
1926 Con::warnf("Cannot add path expando '%s' with path '%s' as the path is an invalid length.", pExpandoName, pPath);
1927 return;
1928 }
1929
1930 // Remove any terminating slash.
1931 if (pathBuffer[pathLength - 1] == '/')
1932 pathBuffer[pathLength - 1] = 0;
1933
1934 // Fetch expanded path.
1935 StringTableEntry expandedPath = StringTable->insert(pathBuffer);
1936
1937 // Info.
1938#if defined(TORQUE_DEBUG)
1939 Con::printf("Adding path expando of '%s' as '%s'.", expandoName, expandedPath);
1940#endif
1941
1942 // Find any existing path expando.
1943 typePathExpandoMap::iterator expandoItr = PathExpandos.find(pExpandoName);
1944
1945 // Does the expando exist?
1946 if (expandoItr != PathExpandos.end())
1947 {
1948 // Yes, so modify the path.
1949 expandoItr->value = expandedPath;

Callers 2

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