Skip to content

Commit

Permalink
enhancement: try to detect files with different capitalization in ext…
Browse files Browse the repository at this point in the history
…ensions (#1611)

When opening files with zfile, try to check for different capitalization cases in the file extension.
Hopefully this should cover incorrect filenames in CD images, where the .CUE file refers to one filename but what actually exists has a different capitalization (e.g. mp3 vs MP3)
  • Loading branch information
midwan committed Jan 25, 2025
1 parent e8f46f4 commit e128d19
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/zfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,26 @@ static struct zfile *zfile_fopenx2 (const TCHAR *name, const TCHAR *mode, int ma
if (f)
return f;
}
#ifdef AMIBERRY
// capitalize file extension then try again
TCHAR *ext = _tcsrchr(tmp, '.');
if (ext) {
for (TCHAR *p = ext; *p; ++p) {
*p = _totupper(*p);
}
f = zfile_fopen_x(tmp, mode, mask, index);
if (f)
return f;

// try again with lowercase extension
for (TCHAR *p = ext; *p; ++p) {
*p = _totlower(*p);
}
f = zfile_fopen_x(tmp, mode, mask, index);
if (f)
return f;
}
#endif
#if 0
name += 2;
if (name[0] == '/' || name[0] == '\\')
Expand Down

0 comments on commit e128d19

Please # to comment.