| 1890 | //----------------------------------------------------------------------------- |
| 1891 | |
| 1892 | void 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; |