-------------------------------------------------------------------------------
| 311 | } |
| 312 | //------------------------------------------------------------------------------- |
| 313 | int CMaterialManager::FindValidPath(aiString* p_szString) |
| 314 | { |
| 315 | ai_assert(nullptr != p_szString); |
| 316 | aiString pcpy = *p_szString; |
| 317 | if ('*' == p_szString->data[0]) { |
| 318 | // '*' as first character indicates an embedded file |
| 319 | return 5; |
| 320 | } |
| 321 | |
| 322 | // first check whether we can directly load the file |
| 323 | FILE* pFile = fopen(p_szString->data,"rb"); |
| 324 | if (pFile) { |
| 325 | fclose(pFile); |
| 326 | } |
| 327 | else { |
| 328 | // check whether we can use the directory of the asset as relative base |
| 329 | char szTemp[MAX_PATH*2], tmp2[MAX_PATH*2]; |
| 330 | strcpy(szTemp, g_szFileName); |
| 331 | strcpy(tmp2,szTemp); |
| 332 | |
| 333 | char* szData = p_szString->data; |
| 334 | if (*szData == '\\' || *szData == '/')++szData; |
| 335 | |
| 336 | char* szEnd = strrchr(szTemp,'\\'); |
| 337 | if (!szEnd) |
| 338 | { |
| 339 | szEnd = strrchr(szTemp,'/'); |
| 340 | if (!szEnd)szEnd = szTemp; |
| 341 | } |
| 342 | szEnd++; |
| 343 | *szEnd = 0; |
| 344 | strcat(szEnd,szData); |
| 345 | |
| 346 | |
| 347 | pFile = fopen(szTemp,"rb"); |
| 348 | if (!pFile) |
| 349 | { |
| 350 | // convert the string to lower case |
| 351 | for (unsigned int i = 0;;++i) |
| 352 | { |
| 353 | if ('\0' == szTemp[i])break; |
| 354 | szTemp[i] = (char)tolower((unsigned char)szTemp[i]); |
| 355 | } |
| 356 | |
| 357 | if(TryLongerPath(szTemp,p_szString))return 1; |
| 358 | *szEnd = 0; |
| 359 | |
| 360 | // search common sub directories |
| 361 | strcat(szEnd,"tex\\"); |
| 362 | strcat(szEnd,szData); |
| 363 | |
| 364 | pFile = fopen(szTemp,"rb"); |
| 365 | if (!pFile) |
| 366 | { |
| 367 | if(TryLongerPath(szTemp,p_szString))return 1; |
| 368 | |
| 369 | *szEnd = 0; |
| 370 |
no outgoing calls
no test coverage detected