Support case-insensitive audio file names. (fixes #33)

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-03-07 13:13:32 -05:00
parent 078b765143
commit cf6e87f6f2

View File

@ -191,13 +191,28 @@ public class OsuParser {
try {
switch (tokens[0]) {
case "AudioFilename":
File audioFileName = new File(file.getParent(), tokens[1]);
File audioFileName = new File(dir, tokens[1]);
if (!osuFiles.isEmpty()) {
// if possible, reuse the same File object from another OsuFile in the group
File groupAudioFileName = osuFiles.get(0).audioFilename;
if (audioFileName.equals(groupAudioFileName))
if (tokens[1].equalsIgnoreCase(groupAudioFileName.getName()))
audioFileName = groupAudioFileName;
}
if (!audioFileName.isFile()) {
// try to find the file with a case-insensitive match
boolean match = false;
for (String s : dir.list()) {
if (s.equalsIgnoreCase(tokens[1])) {
audioFileName = new File(dir, s);
match = true;
break;
}
}
if (!match) {
Log.error(String.format("File not found: '%s'", tokens[1]));
return null;
}
}
osu.audioFilename = audioFileName;
break;
case "AudioLeadIn":