| 380 | } |
| 381 | |
| 382 | std::string ImageTable::FindLegacyObject(const std::string& name) |
| 383 | { |
| 384 | const auto& env = GetContext()->GetPlatformEnvironment(); |
| 385 | auto objectsPath = env.GetDirectoryPath(DirBase::rct2, DirId::objects); |
| 386 | auto objectPath = Path::Combine(objectsPath, name); |
| 387 | if (File::Exists(objectPath)) |
| 388 | { |
| 389 | return objectPath; |
| 390 | } |
| 391 | |
| 392 | std::string altName = name; |
| 393 | auto rangeStart = name.find(".DAT"); |
| 394 | if (rangeStart != std::string::npos) |
| 395 | { |
| 396 | altName.replace(rangeStart, 4, ".POB"); |
| 397 | } |
| 398 | objectPath = Path::Combine(objectsPath, altName); |
| 399 | if (File::Exists(objectPath)) |
| 400 | { |
| 401 | return objectPath; |
| 402 | } |
| 403 | |
| 404 | if (!File::Exists(objectPath)) |
| 405 | { |
| 406 | // Search recursively for any file with the target name (case insensitive) |
| 407 | auto filter = Path::Combine(objectsPath, u8"*.dat;*.pob"); |
| 408 | auto scanner = Path::ScanDirectory(filter, true); |
| 409 | while (scanner->Next()) |
| 410 | { |
| 411 | auto currentName = Path::GetFileName(scanner->GetPathRelative()); |
| 412 | if (String::iequals(currentName, name) || String::iequals(currentName, altName)) |
| 413 | { |
| 414 | objectPath = scanner->GetPath(); |
| 415 | break; |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | return objectPath; |
| 420 | } |
| 421 | |
| 422 | ImageTable::~ImageTable() |
| 423 | { |
nothing calls this directly
no test coverage detected