From 99bc9d1fb4bccae0785d731711e3b1009de1b394 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 15 Feb 2012 02:18:57 +0300 Subject: Replace some hardcoded dir separator to physfs. --- src/chatlogger.cpp | 12 ++++++++++-- src/client.cpp | 22 ++++++++++++---------- src/map.cpp | 3 ++- src/resources/resourcemanager.cpp | 4 ++-- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp index 33763e561..b8418edda 100644 --- a/src/chatlogger.cpp +++ b/src/chatlogger.cpp @@ -42,6 +42,8 @@ #include "utils/mkdir.h" #include "utils/stringutils.h" +#include + #include "debug.h" ChatLogger::ChatLogger() : @@ -172,11 +174,17 @@ void ChatLogger::setServerName(const std::string &serverName) secureName(mServerName); if (mLogDir != "") { - DIR *dir = opendir((mLogDir + "/" + mServerName).c_str()); + DIR *dir = opendir((mLogDir + PHYSFS_getDirSeparator() + + mServerName).c_str()); if (!dir) - mkdir_r((mLogDir + "/" + mServerName).c_str()); + { + mkdir_r((mLogDir + PHYSFS_getDirSeparator() + + mServerName).c_str()); + } else + { closedir(dir); + } } } diff --git a/src/client.cpp b/src/client.cpp index ed3656ee0..4bd60e977 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -443,7 +443,8 @@ void Client::gameInit() } else { - mOptions.dataPath = branding.getDirectory() + "/" + mOptions.dataPath = branding.getDirectory() + + PHYSFS_getDirSeparator() + branding.getStringValue("dataPath"); } mOptions.skipUpdate = true; @@ -1137,17 +1138,17 @@ int Client::gameExec() } else if (loginData.updateType & LoginData::Upd_Skip) { - UpdaterWindow::loadLocalUpdates(mLocalDataDir + "/" - + mUpdatesDir); + UpdaterWindow::loadLocalUpdates(mLocalDataDir + + PHYSFS_getDirSeparator() + mUpdatesDir); mState = STATE_LOAD_DATA; } else { logger->log1("State: UPDATE"); mCurrentDialog = new UpdaterWindow(mUpdateHost, - mLocalDataDir + "/" + mUpdatesDir, - mOptions.dataPath.empty(), - loginData.updateType); + mLocalDataDir + PHYSFS_getDirSeparator() + + mUpdatesDir, mOptions.dataPath.empty(), + loginData.updateType); } break; @@ -1175,7 +1176,8 @@ int Client::gameExec() "zip", false); - resman->addToSearchPath(mLocalDataDir + "/" + resman->addToSearchPath(mLocalDataDir + + PHYSFS_getDirSeparator() + mUpdatesDir + "/local/", false); } @@ -1610,7 +1612,7 @@ void Client::initConfigDir() if (mConfigDir.empty()) { #ifdef __APPLE__ - mConfigDir = mLocalDataDir + "/" + mConfigDir = mLocalDataDir + PHYSFS_getDirSeparator() + branding.getValue("appShort", "mana"); #elif defined __HAIKU__ mConfigDir = std::string(PHYSFS_getUserDir()) + @@ -1642,7 +1644,7 @@ void Client::initConfigDir() */ void Client::initServerConfig(std::string serverName) { - mServerConfigDir = mConfigDir + "/" + serverName; + mServerConfigDir = mConfigDir + PHYSFS_getDirSeparator() + serverName; if (mkdir_r(mServerConfigDir.c_str())) { @@ -1877,7 +1879,7 @@ void Client::initScreenshotDir() if (!configScreenshotSuffix.empty()) { - mScreenshotDir += "/" + configScreenshotSuffix; + mScreenshotDir += PHYSFS_getDirSeparator() + configScreenshotSuffix; // config.setValue("screenshotDirectorySuffix", // configScreenshotSuffix); } diff --git a/src/map.cpp b/src/map.cpp index 3ea9989a4..b8767e5e4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -42,6 +42,7 @@ #include "utils/mkdir.h" #include +#include #include @@ -1251,7 +1252,7 @@ void Map::saveExtraLayer() std::string Map::getUserMapDirectory() const { - return Client::getServerConfigDirectory() + "/" + return Client::getServerConfigDirectory() + PHYSFS_getDirSeparator() + getProperty("_realfilename"); } diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 7adeaa268..ec8764a44 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -329,12 +329,12 @@ std::string ResourceManager::getPath(const std::string &file) // if the file is not in the search path, then its nullptr if (tmp) { - path = std::string(tmp) + "/" + file; + path = std::string(tmp) + PHYSFS_getDirSeparator() + file; } else { // if not found in search path return the default path - path = Client::getPackageDirectory() + "/" + file; + path = Client::getPackageDirectory() + PHYSFS_getDirSeparator() + file; } return path; -- cgit v1.2.3-70-g09d2