diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-04-02 12:29:20 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-04-02 12:29:20 +0000 |
commit | 395193416fab99ececba3db11f003632c35e4dce (patch) | |
tree | cfcb036098a6a2fa5e2199a3d285f006850677fb | |
parent | 5fae2ae363daf4360ca3b3ce7be0e34792dd21ee (diff) |
make probably-audio-file suffix detection case insensitive
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3207 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/ardour/audiofilesource.cc | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 0ef9fb2dbc..ba90026740 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -696,29 +696,39 @@ AudioFileSource::setup_peakfile () bool AudioFileSource::safe_file_extension(ustring file) { - return !(file.rfind(".wav") == ustring::npos && - file.rfind(".aiff")== ustring::npos && - file.rfind(".caf")== ustring::npos && - file.rfind(".aif") == ustring::npos && - file.rfind(".amb") == ustring::npos && - file.rfind(".snd") == ustring::npos && - file.rfind(".au") == ustring::npos && - file.rfind(".raw") == ustring::npos && - file.rfind(".sf") == ustring::npos && - file.rfind(".cdr") == ustring::npos && - file.rfind(".smp") == ustring::npos && - file.rfind(".maud")== ustring::npos && - file.rfind(".vwe") == ustring::npos && - file.rfind(".paf") == ustring::npos && + const char* suffixes[] = { + ".wav", ".WAV", + ".aiff", ".AIFF", + ".caf", ".CAF", + ".aif", ".AIF", + ".amb", ".AMB", + ".snd", ".SND", + ".au", ".AU", + ".raw", ".RAW", + ".sf", ".SF", + ".cdr", ".CDR", + ".smp", ".SMP", + ".maud", ".MAUD", + ".vwe", ".VWE", + ".paf", #ifdef HAVE_FLAC - file.rfind(".flac")== ustring::npos && + ".flac", ".FLAC", #endif // HAVE_FLAC #ifdef HAVE_COREAUDIO - file.rfind(".mp3") == ustring::npos && - file.rfind(".aac") == ustring::npos && - file.rfind(".mp4") == ustring::npos && + ".mp3", ".MP3", + ".aac", ".AAC", + ".mp4", ".MP4", #endif // HAVE_COREAUDIO - file.rfind(".voc") == ustring::npos); + ".voc", ".VOC" + }; + + for (size_t n = 0; n < sizeof(suffixes)/sizeof(suffixes[0]); ++n) { + if (file.rfind (suffixes[n]) == file.length() - strlen (suffixes[n])) { + return true; + } + } + + return false; } void |