--- a/QTfrontend/team.cpp Tue Aug 13 16:12:54 2013 +0400
+++ b/QTfrontend/team.cpp Fri Aug 16 12:27:41 2013 +0400
@@ -171,7 +171,7 @@
bool HWTeam::loadFromFile()
{
- QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0);
+ QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name)), QSettings::IniFormat, 0);
teamfile.setIniCodec("UTF-8");
m_name = teamfile.value("Team/Name", m_name).toString();
m_grave = teamfile.value("Team/Grave", "Statue").toString();
@@ -204,7 +204,7 @@
bool HWTeam::fileExists()
{
- QFile f(QString("physfs://Teams/%1.hwt").arg(m_name));
+ QFile f(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
return f.exists();
}
@@ -212,7 +212,7 @@
{
if(m_isNetTeam)
return false;
- QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(m_name));
+ QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
cfgfile.remove();
return true;
}
@@ -221,12 +221,12 @@
{
if (OldTeamName != m_name)
{
- QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(OldTeamName));
+ QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(OldTeamName)));
cfgfile.remove();
OldTeamName = m_name;
}
- QString fileName = QString("physfs://Teams/%1.hwt").arg(m_name);
+ QString fileName = QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name));
DataManager::ensureFileExists(fileName);
QSettings teamfile(fileName, QSettings::IniFormat, 0);
teamfile.setIniCodec("UTF-8");
--- a/QTfrontend/util/DataManager.cpp Tue Aug 13 16:12:54 2013 +0400
+++ b/QTfrontend/util/DataManager.cpp Fri Aug 16 12:27:41 2013 +0400
@@ -199,6 +199,15 @@
return m_settingsFileName;
}
+QString DataManager::safeFileName(QString fileName)
+{
+ fileName.replace('\\', '_');
+ fileName.replace('/', '_');
+ fileName.replace(':', '_');
+
+ return fileName;
+}
+
void DataManager::reload()
{
// removed for now (also code was a bit unclean, could lead to segfault if
--- a/QTfrontend/util/DataManager.h Tue Aug 13 16:12:54 2013 +0400
+++ b/QTfrontend/util/DataManager.h Fri Aug 16 12:27:41 2013 +0400
@@ -119,6 +119,8 @@
QString settingsFileName();
+ static QString safeFileName(QString fileName);
+
static bool ensureFileExists(const QString & fileName);
public slots: