aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aoapplication.h1
-rw-r--r--courtroom.cpp2
-rw-r--r--main.cpp8
-rw-r--r--path_functions.cpp31
4 files changed, 32 insertions, 10 deletions
diff --git a/aoapplication.h b/aoapplication.h
index f69a0ea8..0cb2c78c 100644
--- a/aoapplication.h
+++ b/aoapplication.h
@@ -107,6 +107,7 @@ public:
QString get_background_path();
QString get_default_background_path();
QString get_evidence_path();
+ QString get_case_sensitive_path(QString p_dir, QString p_file);
////// Functions for reading and writing files //////
// Implementations file_functions.cpp
diff --git a/courtroom.cpp b/courtroom.cpp
index 5c552a12..5c3f966d 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -748,7 +748,7 @@ void Courtroom::list_music()
{
ui_music_list->addItem(i_song);
- QString song_path = ao_app->get_base_path() + "sounds/music/" + i_song.toLower();
+ QString song_path = ao_app->get_music_path(i_song);
if (file_exists(song_path))
ui_music_list->item(n_listed_songs)->setBackground(found_brush);
diff --git a/main.cpp b/main.cpp
index a690f3cf..5696e2e0 100644
--- a/main.cpp
+++ b/main.cpp
@@ -8,14 +8,6 @@
#include <QDebug>
-//this is a quite broad generalization
-//the most common OSes(mac and windows) are _usually_ case insensitive
-//however, there do exist mac installations with case sensitive filesystems
-//in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac
-#if (defined (LINUX) || defined (__linux__))
-#define CASE_SENSITIVE_FILESYSTEM
-#endif
-
int main(int argc, char *argv[])
{
#if QT_VERSION > QT_VERSION_CHECK(5, 6, 0)
diff --git a/path_functions.cpp b/path_functions.cpp
index 820c05a6..5c4972f0 100644
--- a/path_functions.cpp
+++ b/path_functions.cpp
@@ -4,10 +4,20 @@
#include <QDir>
#include <QDebug>
#include <QStandardPaths>
+#include <QRegExp>
#ifdef BASE_OVERRIDE
#include "base_override.h"
#endif
+
+//this is a quite broad generalization
+//the most common OSes(mac and windows) are _usually_ case insensitive
+//however, there do exist mac installations with case sensitive filesystems
+//in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac
+#if (defined (LINUX) || defined (__linux__))
+#define CASE_SENSITIVE_FILESYSTEM
+#endif
+
QString base_path = "";
QString AOApplication::get_base_path()
@@ -68,7 +78,11 @@ QString AOApplication::get_sounds_path()
}
QString AOApplication::get_music_path(QString p_song)
{
- return get_base_path() + "sounds/music/" + p_song.toLower();
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return get_base_path() + "sounds/music/" + p_song;
+#else
+ return get_case_sensitive_path(get_base_path() + "sounds/music/", p_song);
+#endif
}
QString AOApplication::get_background_path()
@@ -96,6 +110,21 @@ QString AOApplication::get_evidence_path()
return get_base_path() + default_path;
}
+QString AOApplication::get_case_sensitive_path(QString p_dir, QString p_file) {
+ qDebug() << "calling get_case_sensitive_path";
+ QRegExp file_rx = QRegExp(p_file, Qt::CaseInsensitive);
+ QStringList files = QDir(p_dir).entryList();
+ int result = files.indexOf(file_rx);
+
+ if (result != -1) {
+ QString path = p_dir + files.at(result);
+ qDebug() << "returning " << path;
+ return path;
+ }
+ //if nothing is found, let the caller handle the missing file
+ return p_dir + p_file;
+}
+
QString Courtroom::get_background_path()
{
return ao_app->get_base_path() + "background/" + current_background.toLower() + "/";