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

Function expandPath

Engine/source/console/console.cpp:2064–2224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2062//-----------------------------------------------------------------------------
2063
2064bool 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);

Callers 15

isBasePathFunction · 0.85
scanModulesMethod · 0.85
copyModuleMethod · 0.85
canMergeModulesMethod · 0.85
mergeModulesMethod · 0.85
expandAssetFilePathMethod · 0.85
addDeclaredAssetMethod · 0.85
loadAssetTagsMethod · 0.85
saveAssetTagsMethod · 0.85
findAssetLooseFileMethod · 0.85
scanDeclaredAssetsMethod · 0.85

Calls 10

getPathExpandoFunction · 0.85
errorfFunction · 0.85
ensureTrailingSlashFunction · 0.85
dStrcpyFunction · 0.85
dSprintfFunction · 0.85
stripRepeatSlashesFunction · 0.85
dStrncpyFunction · 0.85
dStrncatFunction · 0.85
dStrlenFunction · 0.50
dStrrchrFunction · 0.50

Tested by

no test coverage detected