| 2062 | //----------------------------------------------------------------------------- |
| 2063 | |
| 2064 | bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWorkingDirectoryHint, const bool ensureTrailingSlash) |
| 2065 | { |
| 2066 | char pathBuffer[2048]; |
| 2067 | const char* pSrc = pSrcPath; |
| 2068 | char* pSlash; |
| 2069 | |
| 2070 | // Fetch leading character. |
| 2071 | const char leadingToken = *pSrc; |
| 2072 | |
| 2073 | // Fetch following token. |
| 2074 | const char followingToken = leadingToken != 0 ? pSrc[1] : 0; |
| 2075 | |
| 2076 | // Expando. |
| 2077 | if (leadingToken == '^') |
| 2078 | { |
| 2079 | // Initial prefix search. |
| 2080 | const char* pPrefixSrc = pSrc + 1; |
| 2081 | char* pPrefixDst = pathBuffer; |
| 2082 | |
| 2083 | // Search for end of expando. |
| 2084 | while (*pPrefixSrc != '/' && *pPrefixSrc != 0) |
| 2085 | { |
| 2086 | // Copy prefix character. |
| 2087 | *pPrefixDst++ = *pPrefixSrc++; |
| 2088 | } |
| 2089 | |
| 2090 | // Yes, so terminate the expando string. |
| 2091 | *pPrefixDst = 0; |
| 2092 | |
| 2093 | // Fetch the expando path. |
| 2094 | StringTableEntry expandoPath = getPathExpando(pathBuffer); |
| 2095 | |
| 2096 | // Does the expando exist? |
| 2097 | if (expandoPath == NULL) |
| 2098 | { |
| 2099 | // No, so error. |
| 2100 | Con::errorf("expandPath() : Could not find path expando '%s' for path '%s'.", pathBuffer, pSrcPath); |
| 2101 | |
| 2102 | // Are we ensuring the trailing slash? |
| 2103 | if (ensureTrailingSlash) |
| 2104 | { |
| 2105 | // Yes, so ensure it. |
| 2106 | Con::ensureTrailingSlash(pDstPath, pSrcPath); |
| 2107 | } |
| 2108 | else |
| 2109 | { |
| 2110 | // No, so just use the source path. |
| 2111 | dStrcpy(pDstPath, pSrcPath); |
| 2112 | } |
| 2113 | |
| 2114 | return false; |
| 2115 | } |
| 2116 | |
| 2117 | // Skip the expando and the following slash. |
| 2118 | pSrc += dStrlen(pathBuffer) + 1; |
| 2119 | |
| 2120 | // Format the output path. |
| 2121 | dSprintf(pathBuffer, sizeof(pathBuffer), "%s/%s", expandoPath, pSrc); |
no test coverage detected