* Takes a path and tries to find it based on the * system's case-sensitivity. * @param base Base unaltered path. * @param path Full path to check for casing. * @return Correct filename or "" if it doesn't exist. * @note There's no actual method for figuring out the correct * filename on case-sensitive systems, this is just a workaround. */
| 309 | * filename on case-sensitive systems, this is just a workaround. |
| 310 | */ |
| 311 | std::string caseInsensitive(const std::string &base, const std::string &path) |
| 312 | { |
| 313 | std::string fullPath = base + path, newPath = path; |
| 314 | |
| 315 | // Try all various case mutations |
| 316 | // Normal unmangled |
| 317 | if (fileExists(fullPath.c_str())) |
| 318 | { |
| 319 | return fullPath; |
| 320 | } |
| 321 | |
| 322 | // UPPERCASE |
| 323 | std::transform(newPath.begin(), newPath.end(), newPath.begin(), toupper); |
| 324 | fullPath = base + newPath; |
| 325 | if (fileExists(fullPath.c_str())) |
| 326 | { |
| 327 | return fullPath; |
| 328 | } |
| 329 | |
| 330 | // lowercase |
| 331 | std::transform(newPath.begin(), newPath.end(), newPath.begin(), tolower); |
| 332 | fullPath = base + newPath; |
| 333 | if (fileExists(fullPath.c_str())) |
| 334 | { |
| 335 | return fullPath; |
| 336 | } |
| 337 | |
| 338 | // If we got here nothing can help us |
| 339 | return ""; |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Takes a path and tries to find it based on the |
no test coverage detected