--- a/QTfrontend/util/DataManager.cpp Sun Oct 21 00:32:32 2012 +0400
+++ b/QTfrontend/util/DataManager.cpp Sun Oct 21 00:33:38 2012 +0400
@@ -39,12 +39,6 @@
DataManager::DataManager()
{
- m_userData = new QDir(cfgdir->absolutePath());
- if (!m_userData->cd("Data"))
- m_userData = NULL;
-
- m_defaultData = new QDir(datadir->absolutePath());
-
m_hatModel = NULL;
m_mapModel = NULL;
m_themeModel = NULL;
@@ -66,20 +60,8 @@
const QStringList & nameFilters
) const
{
- QStringList result;
-
- if (m_userData != NULL)
- {
- QDir tmpDir(*m_userData);
- if (tmpDir.cd(subDirectory))
- result.append(tmpDir.entryList(nameFilters, filters));
- }
-
- QDir tmpDir(*m_defaultData);
- if (tmpDir.cd(subDirectory))
- result.append(tmpDir.entryList(nameFilters, filters));
-
- result.removeDuplicates();
+ QDir tmpDir(QString("physfs://%1").arg(subDirectory));
+ QStringList result = tmpDir.entryList(nameFilters, filters);
// sort case-insensitive
QMap<QString, QString> sortedFileNames;
@@ -96,34 +78,22 @@
QString DataManager::findFileForRead(
const QString & relativeDataFilePath) const
{
- QString path;
-
- if (m_userData != NULL)
- path = m_userData->absolutePath()+"/"+relativeDataFilePath;
+ QString path("physfs://%1");
- if ((!path.isEmpty()) && (!QFile::exists(path)))
- path = m_defaultData->absolutePath()+"/"+relativeDataFilePath;
-
- return path;
+ return path.arg(relativeDataFilePath);
}
QString DataManager::findFileForWrite(
const QString & relativeDataFilePath) const
{
- if (m_userData != NULL)
- {
- QString path = m_userData->absolutePath()+"/"+relativeDataFilePath;
+ QString path("physfs://%1");
- // create folders if needed
- QDir tmp;
- tmp.mkpath(QFileInfo(path).absolutePath());
+ // create folders if needed
+ QDir tmp;
+ tmp.mkpath(QFileInfo(path.arg(relativeDataFilePath)).absolutePath());
- return path;
- }
-
-
- return "";
+ return path;
}
GameStyleModel * DataManager::gameStyleModel()
--- a/QTfrontend/util/DataManager.h Sun Oct 21 00:32:32 2012 +0400
+++ b/QTfrontend/util/DataManager.h Sun Oct 21 00:33:38 2012 +0400
@@ -152,9 +152,6 @@
*/
DataManager();
- QDir * m_defaultData; ///< directory of the installed data
- QDir * m_userData; ///< directory of custom data in the user's directory
-
GameStyleModel * m_gameStyleModel; ///< game style model instance
HatModel * m_hatModel; ///< hat model instance
MapModel * m_mapModel; ///< map model instance