summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/chatlogger.cpp9
-rw-r--r--src/client.cpp24
-rw-r--r--src/main.cpp2
-rw-r--r--src/map.cpp2
-rw-r--r--src/resources/resourcemanager.cpp8
-rw-r--r--src/utils/paths.cpp2
-rw-r--r--src/utils/physfstools.cpp11
-rw-r--r--src/utils/physfstools.h3
8 files changed, 32 insertions, 29 deletions
diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp
index 3b1cbc771..83292411e 100644
--- a/src/chatlogger.cpp
+++ b/src/chatlogger.cpp
@@ -170,17 +170,12 @@ void ChatLogger::setServerName(const std::string &serverName)
secureName(mServerName);
if (mLogDir != "")
{
- DIR *const dir = opendir((mLogDir + PhysFs::getDirSeparator()
+ DIR *const dir = opendir((mLogDir + dirSeparator
+ mServerName).c_str());
if (!dir)
- {
- mkdir_r((mLogDir + PhysFs::getDirSeparator()
- + mServerName).c_str());
- }
+ mkdir_r((mLogDir + dirSeparator + mServerName).c_str());
else
- {
closedir(dir);
- }
}
}
diff --git a/src/client.cpp b/src/client.cpp
index 9763c3300..f458ca49f 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -501,8 +501,7 @@ void Client::gameInit()
}
else
{
- mOptions.dataPath = branding.getDirectory()
- + PhysFs::getDirSeparator()
+ mOptions.dataPath = branding.getDirectory() + dirSeparator
+ branding.getStringValue("dataPath");
}
mOptions.skipUpdate = true;
@@ -1329,16 +1328,15 @@ int Client::gameExec()
else if (loginData.updateType & LoginData::Upd_Skip)
{
UpdaterWindow::loadLocalUpdates(mLocalDataDir
- + PhysFs::getDirSeparator() + mUpdatesDir);
+ + dirSeparator + mUpdatesDir);
mState = STATE_LOAD_DATA;
}
else
{
logger->log1("State: UPDATE");
mCurrentDialog = new UpdaterWindow(mUpdateHost,
- mLocalDataDir + PhysFs::getDirSeparator()
- + mUpdatesDir, mOptions.dataPath.empty(),
- loginData.updateType);
+ mLocalDataDir + dirSeparator + mUpdatesDir,
+ mOptions.dataPath.empty(), loginData.updateType);
}
BLOCK_END("Client::gameExec STATE_UPDATE")
break;
@@ -1369,8 +1367,7 @@ int Client::gameExec()
"zip",
false);
- resman->addToSearchPath(mLocalDataDir
- + PhysFs::getDirSeparator()
+ resman->addToSearchPath(mLocalDataDir + dirSeparator
+ mUpdatesDir + "/local/", false);
}
@@ -1886,7 +1883,7 @@ void Client::initLocalDataDir()
void Client::initTempDir()
{
- mTempDir = mLocalDataDir + PhysFs::getDirSeparator() + "temp";
+ mTempDir = mLocalDataDir + dirSeparator + "temp";
if (mkdir_r(mTempDir.c_str()))
{
@@ -1902,7 +1899,7 @@ void Client::initConfigDir()
if (mConfigDir.empty())
{
#ifdef __APPLE__
- mConfigDir = mLocalDataDir + PhysFs::getDirSeparator()
+ mConfigDir = mLocalDataDir + dirSeparator
+ branding.getValue("appShort", "mana");
#elif defined __HAIKU__
mConfigDir = std::string(PhysFs::getUserDir()) +
@@ -1937,7 +1934,7 @@ void Client::initConfigDir()
*/
void Client::initServerConfig(std::string serverName)
{
- mServerConfigDir = mConfigDir + PhysFs::getDirSeparator() + serverName;
+ mServerConfigDir = mConfigDir + dirSeparator + serverName;
if (mkdir_r(mServerConfigDir.c_str()))
{
@@ -2189,10 +2186,7 @@ void Client::initScreenshotDir()
branding.getValue("appShort", "mana");
if (!configScreenshotSuffix.empty())
- {
- mScreenshotDir += PhysFs::getDirSeparator()
- + configScreenshotSuffix;
- }
+ mScreenshotDir += dirSeparator + configScreenshotSuffix;
}
}
}
diff --git a/src/main.cpp b/src/main.cpp
index a7817d31a..c940dd6a4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -258,6 +258,8 @@ int main(int argc, char *argv[])
return 1;
}
+ PhysFs::updateDirSeparator();
+
atexit((void(*)()) PHYSFS_deinit);
XML::initXML();
diff --git a/src/map.cpp b/src/map.cpp
index c30592073..2812f6eed 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1223,7 +1223,7 @@ void Map::saveExtraLayer() const
std::string Map::getUserMapDirectory() const
{
- return Client::getServerConfigDirectory() + PhysFs::getDirSeparator()
+ return Client::getServerConfigDirectory() + dirSeparator
+ getProperty("_realfilename");
}
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index dbd2f60cf..1d6347d75 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -328,7 +328,7 @@ void ResourceManager::searchAndAddArchives(const std::string &path,
const std::string &ext,
const bool append) const
{
- const char *const dirSep = PhysFs::getDirSeparator();
+ const char *const dirSep = dirSeparator;
char **list = PhysFs::enumerateFiles(path.c_str());
for (char **i = list; *i; i++)
@@ -353,7 +353,7 @@ void ResourceManager::searchAndAddArchives(const std::string &path,
void ResourceManager::searchAndRemoveArchives(const std::string &path,
const std::string &ext) const
{
- const char *const dirSep = PhysFs::getDirSeparator();
+ const char *const dirSep = dirSeparator;
char **list = PhysFs::enumerateFiles(path.c_str());
for (char **i = list; *i; i++)
@@ -410,12 +410,12 @@ std::string ResourceManager::getPath(const std::string &file) const
// if the file is not in the search path, then its nullptr
if (tmp)
{
- path = std::string(tmp) + PhysFs::getDirSeparator() + file;
+ path = std::string(tmp) + dirSeparator + file;
}
else
{
// if not found in search path return the default path
- path = Client::getPackageDirectory() + PhysFs::getDirSeparator() + file;
+ path = Client::getPackageDirectory() + dirSeparator + file;
}
return path;
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp
index 271178c23..f97ccafcb 100644
--- a/src/utils/paths.cpp
+++ b/src/utils/paths.cpp
@@ -79,7 +79,7 @@ bool checkPath(std::string path)
std::string &fixDirSeparators(std::string &str)
{
- if (*PhysFs::getDirSeparator() == '/')
+ if (dirSeparator[0] == '/')
return str;
return replaceAll(str, "/", "\\");
diff --git a/src/utils/physfstools.cpp b/src/utils/physfstools.cpp
index 06df8fccf..1fcb8fb1b 100644
--- a/src/utils/physfstools.cpp
+++ b/src/utils/physfstools.cpp
@@ -20,11 +20,20 @@
#include "utils/physfstools.h"
+#include "logger.h"
+
+const char *dirSeparator = nullptr;
+
namespace PhysFs
{
+ void updateDirSeparator()
+ {
+ dirSeparator = PHYSFS_getDirSeparator();
+ }
+
const char *getDirSeparator()
{
- return PHYSFS_getDirSeparator();
+ return dirSeparator;
}
const char *getBaseDir()
diff --git a/src/utils/physfstools.h b/src/utils/physfstools.h
index f917a0841..7bfe6b14d 100644
--- a/src/utils/physfstools.h
+++ b/src/utils/physfstools.h
@@ -25,6 +25,7 @@
namespace PhysFs
{
+ void updateDirSeparator();
const char *getDirSeparator();
const char *getBaseDir();
const char *getUserDir();
@@ -42,4 +43,6 @@ namespace PhysFs
bool mkdir(const char *dirName);
}
+extern const char *dirSeparator;
+
#endif // UTILS_PHYSFS_H