added case insensitive path function for those filesystems
This commit is contained in:
parent
e9eefee1da
commit
051c8975ec
@ -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
|
||||
|
@ -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);
|
||||
|
8
main.cpp
8
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)
|
||||
|
@ -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() + "/";
|
||||
|
Loading…
Reference in New Issue
Block a user