| 215 | //----------------------------------------------------------------------------- |
| 216 | |
| 217 | StringTableEntry AssetBase::collapseAssetFilePath(const char* pAssetFilePath) const |
| 218 | { |
| 219 | // Debug Profiling. |
| 220 | PROFILE_SCOPE(AssetBase_CollapseAssetFilePath); |
| 221 | |
| 222 | // Sanity! |
| 223 | AssertFatal(pAssetFilePath != NULL, "Cannot collapse a NULL asset path."); |
| 224 | |
| 225 | // Fetch asset file-path length. |
| 226 | const U32 assetFilePathLength = dStrlen(pAssetFilePath); |
| 227 | |
| 228 | // Are there any characters in the path? |
| 229 | if (assetFilePathLength == 0) |
| 230 | { |
| 231 | // No, so return empty. |
| 232 | return StringTable->EmptyString(); |
| 233 | } |
| 234 | |
| 235 | char assetFilePathBuffer[1024]; |
| 236 | |
| 237 | // Is the asset not owned or private? |
| 238 | if (!getOwned() || getAssetPrivate()) |
| 239 | { |
| 240 | // Yes, so we can only collapse the path using the platform layer. |
| 241 | Con::collapsePath(assetFilePathBuffer, sizeof(assetFilePathBuffer), pAssetFilePath); |
| 242 | return StringTable->insert(assetFilePathBuffer); |
| 243 | } |
| 244 | |
| 245 | // Fetch asset base-path. |
| 246 | StringTableEntry assetBasePath = mpOwningAssetManager->getAssetPath(getAssetId()); |
| 247 | |
| 248 | // Is the asset file-path location within the asset base-path? |
| 249 | if (Con::isBasePath(pAssetFilePath, assetBasePath)) |
| 250 | { |
| 251 | // Yes, so fetch path relative to the asset base-path. |
| 252 | StringTableEntry relativePath = Platform::makeRelativePathName(pAssetFilePath, assetBasePath); |
| 253 | |
| 254 | // Format the collapsed path. |
| 255 | dSprintf(assetFilePathBuffer, sizeof(assetFilePathBuffer), "%s", relativePath); |
| 256 | } |
| 257 | else |
| 258 | { |
| 259 | // No, so we can collapse the path using the platform layer. |
| 260 | Con::collapsePath(assetFilePathBuffer, sizeof(assetFilePathBuffer), pAssetFilePath); |
| 261 | } |
| 262 | |
| 263 | return StringTable->insert(assetFilePathBuffer); |
| 264 | } |
| 265 | |
| 266 | //----------------------------------------------------------------------------- |
| 267 |
nothing calls this directly
no test coverage detected