| 233 | //----------------------------------------------------------------------------- |
| 234 | |
| 235 | StringTableEntry AssetBase::collapseAssetFilePath(const char* pAssetFilePath) const |
| 236 | { |
| 237 | // Debug Profiling. |
| 238 | PROFILE_SCOPE(AssetBase_CollapseAssetFilePath); |
| 239 | |
| 240 | // Sanity! |
| 241 | AssertFatal(pAssetFilePath != NULL, "Cannot collapse a NULL asset path."); |
| 242 | |
| 243 | // Fetch asset file-path length. |
| 244 | const U32 assetFilePathLength = dStrlen(pAssetFilePath); |
| 245 | |
| 246 | // Are there any characters in the path? |
| 247 | if (assetFilePathLength == 0) |
| 248 | { |
| 249 | // No, so return empty. |
| 250 | return StringTable->EmptyString(); |
| 251 | } |
| 252 | |
| 253 | char assetFilePathBuffer[1024]; |
| 254 | |
| 255 | // Is the asset not owned or private? |
| 256 | if (!getOwned() || getAssetPrivate()) |
| 257 | { |
| 258 | // Yes, so we can only collapse the path using the platform layer. |
| 259 | Con::collapsePath(assetFilePathBuffer, sizeof(assetFilePathBuffer), pAssetFilePath); |
| 260 | return StringTable->insert(assetFilePathBuffer); |
| 261 | } |
| 262 | |
| 263 | // Fetch asset base-path. |
| 264 | StringTableEntry assetBasePath = mpOwningAssetManager->getAssetPath(getAssetId()); |
| 265 | |
| 266 | // Is the asset file-path location within the asset base-path? |
| 267 | if (Con::isBasePath(pAssetFilePath, assetBasePath)) |
| 268 | { |
| 269 | // Yes, so fetch path relative to the asset base-path. |
| 270 | StringTableEntry relativePath = Platform::makeRelativePathName(pAssetFilePath, assetBasePath); |
| 271 | |
| 272 | // Format the collapsed path. |
| 273 | dSprintf(assetFilePathBuffer, sizeof(assetFilePathBuffer), "%s", relativePath); |
| 274 | } |
| 275 | else |
| 276 | { |
| 277 | // No, so we can collapse the path using the platform layer. |
| 278 | Con::collapsePath(assetFilePathBuffer, sizeof(assetFilePathBuffer), pAssetFilePath); |
| 279 | } |
| 280 | |
| 281 | return StringTable->insert(assetFilePathBuffer); |
| 282 | } |
| 283 | |
| 284 | //----------------------------------------------------------------------------- |
| 285 |
nothing calls this directly
no test coverage detected