* Takes a foldername and tries to find it in the game's Data folders, * accounting for the system's case-sensitivity and path style. * @param foldername Original foldername. * @return Correct foldername or "" if it doesn't exist. */
| 422 | * @return Correct foldername or "" if it doesn't exist. |
| 423 | */ |
| 424 | std::string getDataFolder(const std::string &foldername) |
| 425 | { |
| 426 | // Correct folder separator |
| 427 | std::string name = foldername; |
| 428 | #ifdef _WIN32 |
| 429 | std::replace(name.begin(), name.end(), '/', PATH_SEPARATOR); |
| 430 | #endif |
| 431 | |
| 432 | // Check current data path |
| 433 | std::string path = caseInsensitiveFolder(Options::getDataFolder(), name); |
| 434 | if (path != "") |
| 435 | { |
| 436 | return path; |
| 437 | } |
| 438 | |
| 439 | // Check every other path |
| 440 | for (std::vector<std::string>::const_iterator i = Options::getDataList().begin(); i != Options::getDataList().end(); ++i) |
| 441 | { |
| 442 | std::string path = caseInsensitiveFolder(*i, name); |
| 443 | if (path != "") |
| 444 | { |
| 445 | Options::setDataFolder(*i); |
| 446 | return path; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | // Give up |
| 451 | return foldername; |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Creates a folder at the specified path. |
no test coverage detected