diff --git a/src/common/cd_image_cue.cpp b/src/common/cd_image_cue.cpp index 876cbaa03..7be980fe5 100644 --- a/src/common/cd_image_cue.cpp +++ b/src/common/cd_image_cue.cpp @@ -94,8 +94,21 @@ bool CDImageCueSheet::OpenAndParse(const char* filename) } if (track_file_index == m_files.size()) { - std::string track_full_filename = basepath + track_filename; + const std::string track_full_filename(basepath + track_filename); std::FILE* track_fp = FileSystem::OpenCFile(track_full_filename.c_str(), "rb"); + if (!track_fp && track_file_index == 0) + { + // many users have bad cuesheets, or they're renamed the files without updating the cuesheet. + // so, try searching for a bin with the same name as the cue, but only for the first referenced file. + const std::string alternative_filename(FileSystem::ReplaceExtension(filename, "bin")); + track_fp = FileSystem::OpenCFile(alternative_filename.c_str(), "rb"); + if (track_fp) + { + Log_WarningPrintf("Your cue sheet references an invalid file '%s', but this was found at '%s' instead.", + track_filename.c_str(), alternative_filename.c_str()); + } + } + if (!track_fp) { Log_ErrorPrintf("Failed to open track filename '%s' (from '%s' and '%s'): errno %d",