* Takes a filename and tries to find it in the game's Data folders, * accounting for the system's case-sensitivity and path style. * @param filename Original filename. * @return Correct filename or "" if it doesn't exist. */
| 386 | * @return Correct filename or "" if it doesn't exist. |
| 387 | */ |
| 388 | std::string getDataFile(const std::string &filename) |
| 389 | { |
| 390 | // Correct folder separator |
| 391 | std::string name = filename; |
| 392 | #ifdef _WIN32 |
| 393 | std::replace(name.begin(), name.end(), '/', PATH_SEPARATOR); |
| 394 | #endif |
| 395 | |
| 396 | // Check current data path |
| 397 | std::string path = caseInsensitive(Options::getDataFolder(), name); |
| 398 | if (path != "") |
| 399 | { |
| 400 | return path; |
| 401 | } |
| 402 | |
| 403 | // Check every other path |
| 404 | for (std::vector<std::string>::const_iterator i = Options::getDataList().begin(); i != Options::getDataList().end(); ++i) |
| 405 | { |
| 406 | std::string path = caseInsensitive(*i, name); |
| 407 | if (path != "") |
| 408 | { |
| 409 | Options::setDataFolder(*i); |
| 410 | return path; |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | // Give up |
| 415 | return filename; |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Takes a foldername and tries to find it in the game's Data folders, |
no test coverage detected