From cf6e87f6f21e613e6161f850a698a5557dcb16e9 Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Sat, 7 Mar 2015 13:13:32 -0500 Subject: [PATCH] Support case-insensitive audio file names. (fixes #33) Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/OsuParser.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/itdelatrisu/opsu/OsuParser.java b/src/itdelatrisu/opsu/OsuParser.java index 920a9bcb..d790a557 100644 --- a/src/itdelatrisu/opsu/OsuParser.java +++ b/src/itdelatrisu/opsu/OsuParser.java @@ -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":