diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-04-03 02:12:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-04-03 18:44:58 +0300 |
commit | 9e72886ee15acc39cbb6075ce32a60a5391ea9f3 (patch) | |
tree | fd7d0b05eeaed5ab0016cad58772cab7456f36b4 /src | |
parent | 49631972db5b965413d4bbe36983a8d5bd203183 (diff) | |
download | plus-9e72886ee15acc39cbb6075ce32a60a5391ea9f3.tar.gz plus-9e72886ee15acc39cbb6075ce32a60a5391ea9f3.tar.bz2 plus-9e72886ee15acc39cbb6075ce32a60a5391ea9f3.tar.xz plus-9e72886ee15acc39cbb6075ce32a60a5391ea9f3.zip |
Replace string::append with pathJoin.
Diffstat (limited to 'src')
-rw-r--r-- | src/actormanager.cpp | 7 | ||||
-rw-r--r-- | src/being/being.cpp | 20 | ||||
-rw-r--r-- | src/configmanager.cpp | 17 | ||||
-rw-r--r-- | src/dirs.cpp | 36 | ||||
-rw-r--r-- | src/fs/files.cpp | 11 | ||||
-rw-r--r-- | src/fs/paths.cpp | 15 | ||||
-rw-r--r-- | src/game.cpp | 4 | ||||
-rw-r--r-- | src/gui/theme.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 5 | ||||
-rw-r--r-- | src/gui/windows/cutinwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/didyouknowwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/helpwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/minimap.cpp | 4 | ||||
-rw-r--r-- | src/gui/windows/serverdialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 99 | ||||
-rw-r--r-- | src/resources/db/emotedb.cpp | 16 | ||||
-rw-r--r-- | src/resources/db/horsedb.cpp | 8 | ||||
-rw-r--r-- | src/resources/iteminfo.cpp | 3 | ||||
-rw-r--r-- | src/resources/map/map.cpp | 8 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 6 | ||||
-rw-r--r-- | src/resources/sprite/spritedef.cpp | 2 | ||||
-rw-r--r-- | src/resources/wallpaper.cpp | 2 | ||||
-rw-r--r-- | src/soundmanager.cpp | 11 | ||||
-rw-r--r-- | src/statuseffect.cpp | 4 |
24 files changed, 144 insertions, 151 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 35be95159..13cbeb286 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -2146,10 +2146,9 @@ void ActorManager::updateNameId(const std::string &name, std::string dir; if (beingId != BeingId_zero) { - dir = settings.usersIdDir; - dir.append(idStr); - dir.append("/"); - dir.append(stringToHexPath(name)); + dir = pathJoin(settings.usersIdDir, + idStr, + stringToHexPath(name)); Files::saveTextFile(dir, "info.txt", (name + "\n").append(dateStr)); diff --git a/src/being/being.cpp b/src/being/being.cpp index 333e60d12..45aa67bac 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2671,7 +2671,7 @@ void Being::setSpriteId(const unsigned int slot, if (!filename.empty()) { equipmentSprite = AnimatedSprite::delayedLoad( - paths.getStringValue("sprites").append(filename)); + pathJoin(paths.getStringValue("sprites"), filename)); } if (equipmentSprite) @@ -2776,7 +2776,7 @@ void Being::setSpriteColor(const unsigned int slot, if (!filename.empty()) { equipmentSprite = AnimatedSprite::delayedLoad( - paths.getStringValue("sprites").append( + pathJoin(paths.getStringValue("sprites"), combineDye(filename, color))); } @@ -2856,7 +2856,7 @@ void Being::setSpriteColorId(const unsigned int slot, { color = info.getDyeColorsString(colorId); equipmentSprite = AnimatedSprite::delayedLoad( - paths.getStringValue("sprites").append( + pathJoin(paths.getStringValue("sprites"), combineDye(filename, color))); } @@ -2942,7 +2942,7 @@ void Being::setSpriteCards(const unsigned int slot, color = info.getDyeColorsString(colorId); equipmentSprite = AnimatedSprite::delayedLoad( - paths.getStringValue("sprites").append( + pathJoin(paths.getStringValue("sprites"), combineDye(filename, color))); } @@ -3034,7 +3034,7 @@ void Being::setTempSprite(const unsigned int slot, color = info.getDyeColorsString(colorId); equipmentSprite = AnimatedSprite::delayedLoad( - paths.getStringValue("sprites").append( + pathJoin(paths.getStringValue("sprites"), combineDye(filename, color))); } @@ -3107,7 +3107,7 @@ void Being::setHairTempSprite(const unsigned int slot, color = info.getDyeColorsString(colorId); equipmentSprite = AnimatedSprite::delayedLoad( - paths.getStringValue("sprites").append( + pathJoin(paths.getStringValue("sprites"), combineDye(filename, color))); } @@ -3179,7 +3179,7 @@ void Being::setSpriteColor(const unsigned int slot, if (!filename.empty()) { equipmentSprite = AnimatedSprite::delayedLoad( - paths.getStringValue("sprites").append( + pathJoin(paths.getStringValue("sprites"), combineDye(filename, color))); } @@ -3445,7 +3445,7 @@ void Being::setGender(const GenderT gender) restrict2 if (!filename.empty()) { equipmentSprite = AnimatedSprite::delayedLoad( - paths.getStringValue("sprites").append( + pathJoin(paths.getStringValue("sprites"), combineDye(filename, beingSlot.color))); } @@ -4557,7 +4557,7 @@ std::string Being::loadComment(const std::string &restrict name, return ""; } - str.append(stringToHexPath(name)).append("/comment.txt"); + str = pathJoin(str, stringToHexPath(name), "comment.txt"); if (Files::existsLocal(str)) { StringVect lines; @@ -4594,7 +4594,7 @@ void Being::saveComment(const std::string &restrict name, default: return; } - dir.append(stringToHexPath(name)); + dir = pathJoin(dir, stringToHexPath(name)); Files::saveTextFile(dir, "comment.txt", (name + "\n").append(comment)); diff --git a/src/configmanager.cpp b/src/configmanager.cpp index f1232235a..eb65d14f3 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -173,8 +173,7 @@ void ConfigManager::initConfiguration() void ConfigManager::backupConfig(const std::string &name) { - const std::string fileName3 = std::string(settings.configDir).append( - "/").append(name); + const std::string fileName3 = pathJoin(settings.configDir, name); StringVect arr; if (Files::existsLocal(fileName3) == false) { @@ -188,11 +187,8 @@ void ConfigManager::backupConfig(const std::string &name) return; arr.clear(); - const std::string tmpName = std::string( - settings.configDir).append( - "/").append( - name).append( - ".tmp"); + const std::string tmpName = pathJoin(settings.configDir, + name).append(".tmp"); Files::copyFile(fileName3, tmpName); if (Files::loadTextFileLocal(tmpName, arr) == false || arr.size() == 0) @@ -203,11 +199,8 @@ void ConfigManager::backupConfig(const std::string &name) arr.clear(); } - const std::string confName = std::string( - settings.configDir).append( - "/").append( - name).append( - ".bak"); + const std::string confName = pathJoin(settings.configDir, + name).append(".bak"); const int maxFileIndex = 5; ::remove((confName + toString(maxFileIndex)).c_str()); for (int f = maxFileIndex; f > 1; f --) diff --git a/src/dirs.cpp b/src/dirs.cpp index d72881545..85383543a 100644 --- a/src/dirs.cpp +++ b/src/dirs.cpp @@ -103,8 +103,8 @@ void extractAssets() logger->log("error: APPDIR is not set!"); return; } - const std::string fileName = std::string(getenv( - "APPDIR")).append("/data.zip"); + const std::string fileName = pathJoin(getenv("APPDIR"), + "data.zip"); logger->log("Extracting asset into: " + fileName); uint8_t *buf = new uint8_t[1000000]; @@ -132,8 +132,8 @@ void extractAssets() } fclose(file); - const std::string fileName2 = std::string(getenv( - "APPDIR")).append("/locale.zip"); + const std::string fileName2 = pathJoin(getenv("APPDIR"), + "locale.zip"); FILE *const file2 = fopen(fileName2.c_str(), "w"); SDL_RWops *const rw = SDL_RWFromFile("manaplus-locale.zip", "r"); if (rw) @@ -177,12 +177,8 @@ void Dirs::extractDataDir() resetProgress(); extractAssets(); - const std::string zipName = std::string(getenv( - "APPDIR")).append( - "/data.zip"); - const std::string dirName = std::string(getenv( - "APPDIR")).append( - "/data"); + const std::string zipName = pathJoin(getenv("APPDIR"), "data.zip"); + const std::string dirName = pathJoin(getenv("APPDIR"), "data"); Files::extractZip(zipName, "data", dirName); Files::extractLocale(); #endif // defined(ANDROID) && defined(USE_SDL2) @@ -397,18 +393,21 @@ void Dirs::initConfigDir() } else { - settings.configDir.append("/mana/").append(branding.getValue( - "appShort", "mana")); + settings.configDir = pathJoin(settings.configDir, + "mana", + branding.getValue("appShort", "mana")); } #elif defined __ANDROID__ - settings.configDir = getSdStoragePath() + branding.getValue( - "appShort", "ManaPlus").append("/config"); + settings.configDir = pathJoin(getSdStoragePath(), + branding.getValue("appShort", "ManaPlus"), + "config"); #elif defined __native_client__ settings.configDir = pathJoin(_nacl_dir, "config"); #else // __APPLE__ - settings.configDir = std::string(VirtFs::getUserDir()).append( - "/.config/mana/").append(branding.getValue("appShort", "mana")); + settings.configDir = pathJoin(VirtFs::getUserDir(), + ".config/mana", + branding.getValue("appShort", "mana")); #endif // __APPLE__ logger->log("Generating config dir: " + settings.configDir); @@ -440,10 +439,7 @@ void Dirs::initUpdatesDir() if (settings.updateHost.length() < 2) { if (settings.updatesDir.empty()) - { - settings.updatesDir = std::string("updates/").append( - settings.serverName); - } + settings.updatesDir = pathJoin("updates", settings.serverName); return; } diff --git a/src/fs/files.cpp b/src/fs/files.cpp index dbbf248d2..215076b99 100644 --- a/src/fs/files.cpp +++ b/src/fs/files.cpp @@ -44,15 +44,14 @@ void Files::extractLocale() { // in future need also remove all locales in local dir - const std::string fileName2 = std::string(getenv( - "APPDIR")).append("/locale.zip"); + const std::string fileName2 = pathJoin(getenv("APPDIR"), "locale.zip"); VirtFs::mountZip(fileName2, Append_false); const std::string localDir = std::string(getenv("APPDIR")).append("/"); VirtList *const rootDirs = VirtFs::enumerateFiles("locale"); FOR_EACH (StringVectCIter, i, rootDirs->names) { - const std::string dir = std::string("locale/").append(*i); + const std::string dir = pathJoin("locale", *i); if (VirtFs::isDirectory(dir)) { const std::string moFile = dir + "/LC_MESSAGES/manaplus.mo"; @@ -112,8 +111,8 @@ void Files::copyVirtFsDir(const std::string &restrict inDir, VirtList *const files = VirtFs::enumerateFiles(inDir); FOR_EACH (StringVectCIter, i, files->names) { - const std::string file = std::string(inDir).append("/").append(*i); - const std::string outDir2 = std::string(outDir).append("/").append(*i); + const std::string file = pathJoin(inDir, *i); + const std::string outDir2 = pathJoin(outDir, *i); if (VirtFs::isDirectory(file)) copyVirtFsDir(file, outDir2); else @@ -257,7 +256,7 @@ void Files::saveTextFile(std::string path, if (!mkdir_r(path.c_str())) { std::ofstream file; - std::string fileName = path.append("/").append(name); + std::string fileName = pathJoin(path, name); file.open(fileName.c_str(), std::ios::out); if (file.is_open()) { diff --git a/src/fs/paths.cpp b/src/fs/paths.cpp index a5941f084..e5fcdd7d3 100644 --- a/src/fs/paths.cpp +++ b/src/fs/paths.cpp @@ -191,12 +191,12 @@ std::string getPicturesDir() std::string file; if (!xdg) { - file = std::string(VirtFs::getUserDir()).append( - "/.config/user-dirs.dirs"); + file = pathJoin(VirtFs::getUserDir(), + ".config/user-dirs.dirs"); } else { - file = std::string(xdg).append("/user-dirs.dirs"); + file = pathJoin(xdg, "user-dirs.dirs"); } StringVect arr; @@ -212,16 +212,13 @@ std::string getPicturesDir() replaceAll(str, "$HOME/", VirtFs::getUserDir()); str = getRealPath(str); if (str.empty()) - str = std::string(VirtFs::getUserDir()).append("Desktop"); + str = pathJoin(VirtFs::getUserDir(), "Desktop"); return str; } } - - return std::string(VirtFs::getUserDir()).append("Desktop"); -#else // WIN32 - - return std::string(VirtFs::getUserDir()).append("Desktop"); #endif // WIN32 + + return pathJoin(VirtFs::getUserDir(), "Desktop"); } std::string getHomePath() diff --git a/src/game.cpp b/src/game.cpp index 9b4542e93..a00c6cfea 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1053,9 +1053,9 @@ void Game::changeMap(const std::string &mapPath) mMapName = mapPath; - std::string fullMap = paths.getValue("maps", "maps/").append( + std::string fullMap = pathJoin(paths.getValue("maps", "maps/"), mMapName).append(".tmx"); - std::string realFullMap = paths.getValue("maps", "maps/").append( + std::string realFullMap = pathJoin(paths.getValue("maps", "maps/"), MapDB::getMapName(mMapName)).append(".tmx"); if (!VirtFs::exists(realFullMap)) diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index b68fa011d..f369c95b3 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -644,13 +644,13 @@ std::string Theme::resolveThemePath(const std::string &path) } // Try the theme - file = getThemePath().append("/").append(file); + file = pathJoin(getThemePath(), file); if (VirtFs::exists(file)) - return getThemePath().append("/").append(path); + return pathJoin(getThemePath(), path); // Backup - return branding.getStringValue("guiPath").append(path); + return pathJoin(branding.getStringValue("guiPath"), path); } Image *Theme::getImageFromTheme(const std::string &path) diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 37621770b..2ebd2ef19 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -1167,8 +1167,9 @@ void SetupItemSound::action(const ActionEvent &event) { if (mSlider && mSlider->getSelected()) { - soundManager.playGuiSfx(branding.getStringValue("systemsounds") - .append(mSlider->getSelectedString()).append(".ogg")); + soundManager.playGuiSfx(pathJoin(branding.getStringValue( + "systemsounds"), + mSlider->getSelectedString()).append(".ogg")); } } else diff --git a/src/gui/windows/cutinwindow.cpp b/src/gui/windows/cutinwindow.cpp index f965a77ee..79bc1e1e9 100644 --- a/src/gui/windows/cutinwindow.cpp +++ b/src/gui/windows/cutinwindow.cpp @@ -84,8 +84,7 @@ void CutInWindow::show(const std::string &name, else { mImage = AnimatedSprite::load( - std::string(paths.getStringValue("cutInsDir")).append( - "/").append( + pathJoin(paths.getStringValue("cutInsDir"), name).append( ".xml")); if (mImage) diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 43251f2dd..f5a01b42d 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -171,7 +171,7 @@ void DidYouKnowWindow::loadFile(const int num) helpPath = paths.getStringValue("help"); StringVect lines; - TranslationManager::translateFile(helpPath.append(file).append(".txt"), + TranslationManager::translateFile(pathJoin(helpPath, file).append(".txt"), translator, lines); for (size_t i = 0, sz = lines.size(); i < sz; ++i) diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 769082516..d0aa30b42 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -149,7 +149,7 @@ void HelpWindow::loadFile(std::string file) helpPath = paths.getStringValue("help"); StringVect lines; - TranslationManager::translateFile(helpPath.append(file).append(".txt"), + TranslationManager::translateFile(pathJoin(helpPath, file).append(".txt"), translator, lines); for (size_t i = 0, sz = lines.size(); i < sz; ++i) diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 2a2d6830a..5d4d867bf 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -176,7 +176,7 @@ void Minimap::setMap(const Map *const map) } else { - std::string tempname = paths.getStringValue("minimaps").append( + std::string tempname = pathJoin(paths.getStringValue("minimaps"), map->getFilename()).append(".png"); std::string minimapName = map->getProperty("minimap"); @@ -187,7 +187,7 @@ void Minimap::setMap(const Map *const map) if (minimapName.empty()) { tempname = pathJoin("graphics/minimaps", - std::string(map->getFilename()).append(".png")); + map->getFilename()).append(".png"); if (VirtFs::exists(tempname)) minimapName = tempname; } diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index d04deb0fb..7c4af2291 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -440,7 +440,7 @@ void ServerDialog::downloadServerList() mDownload = new Net::Download(this, listFile, &downloadUpdate, false, false, true); - mDownload->setFile(std::string(mDir).append("/").append( + mDownload->setFile(pathJoin(mDir, branding.getStringValue("onlineServerFile"))); if (!listFile2.empty()) mDownload->addMirror(listFile2); @@ -478,7 +478,7 @@ static void loadHostsGroup(XmlNodeConstPtr node, void ServerDialog::loadServers(const bool addNew) { - XML::Document doc(std::string(mDir).append("/").append( + XML::Document doc(pathJoin(mDir, branding.getStringValue("onlineServerFile")), UseVirtFs_false, SkipError_false); diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 6ef065eed..c99674072 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -51,6 +51,7 @@ #include "utils/delete2.h" #include "utils/gettext.h" +#include "utils/stringutils.h" #include <sys/stat.h> @@ -596,7 +597,7 @@ void UpdaterWindow::download() else { mDownload = new Net::Download(this, - std::string(mUpdateHost).append("/").append(mCurrentFile), + pathJoin(mUpdateHost, mCurrentFile), &updateProgress, false, false, mValidateXml); @@ -613,8 +614,8 @@ void UpdaterWindow::download() const std::vector<std::string> &mirrors = settings.updateMirrors; FOR_EACH (std::vector<std::string>::const_iterator, it, mirrors) { - mDownload->addMirror(std::string(*it).append( - "/").append(mCurrentFile)); + mDownload->addMirror(pathJoin(*it, + mCurrentFile)); } } } @@ -627,13 +628,13 @@ void UpdaterWindow::download() { if (mDownloadStatus == UpdateDownloadStatus::UPDATE_RESOURCES) { - mDownload->setFile(std::string(mUpdatesDir).append("/").append( - mCurrentFile), mCurrentChecksum); + mDownload->setFile(pathJoin(mUpdatesDir, mCurrentFile), + mCurrentChecksum); } else { - mDownload->setFile(std::string(mUpdatesDir).append( - "/").append(mCurrentFile)); + mDownload->setFile(pathJoin(mUpdatesDir, + mCurrentFile)); } } @@ -650,15 +651,15 @@ void UpdaterWindow::loadUpdates() { if (mUpdateFiles.empty()) { // updates not downloaded - mUpdateFiles = loadXMLFile(std::string(mUpdatesDir).append( - "/").append(xmlUpdateFile), false); + mUpdateFiles = loadXMLFile(pathJoin(mUpdatesDir, xmlUpdateFile), + false); if (mUpdateFiles.empty()) { logger->log("Warning this server does not have a" " %s file falling back to %s", xmlUpdateFile.c_str(), txtUpdateFile.c_str()); - mUpdateFiles = loadTxtFile(std::string(mUpdatesDir).append( - "/").append(txtUpdateFile)); + mUpdateFiles = loadTxtFile(pathJoin(mUpdatesDir, + txtUpdateFile)); } } @@ -681,15 +682,16 @@ void UpdaterWindow::loadUpdates() void UpdaterWindow::loadLocalUpdates(const std::string &dir) { std::vector<UpdateFile> updateFiles = loadXMLFile( - std::string(dir).append("/").append(xmlUpdateFile), false); + pathJoin(dir, xmlUpdateFile), + false); if (updateFiles.empty()) { logger->log("Warning this server does not have a" " %s file falling back to %s", xmlUpdateFile.c_str(), txtUpdateFile.c_str()); - updateFiles = loadTxtFile(std::string(dir).append( - "/").append(txtUpdateFile)); + updateFiles = loadTxtFile(pathJoin(dir, + txtUpdateFile)); } const std::string fixPath = dir + "/fix"; @@ -713,12 +715,13 @@ void UpdaterWindow::loadLocalUpdates(const std::string &dir) void UpdaterWindow::unloadUpdates(const std::string &dir) { std::vector<UpdateFile> updateFiles = loadXMLFile( - std::string(dir).append("/").append(xmlUpdateFile), true); + pathJoin(dir, xmlUpdateFile), + true); if (updateFiles.empty()) { - updateFiles = loadTxtFile(std::string(dir).append( - "/").append(txtUpdateFile)); + updateFiles = loadTxtFile(pathJoin(dir, + txtUpdateFile)); } const std::string fixPath = dir + "/fix"; @@ -738,7 +741,8 @@ void UpdaterWindow::loadManaPlusUpdates(const std::string &dir) { std::string fixPath = dir + "/fix"; std::vector<UpdateFile> updateFiles = loadXMLFile( - std::string(fixPath).append("/").append(xmlUpdateFile), false); + pathJoin(fixPath, xmlUpdateFile), + false); for (unsigned int updateIndex = 0, fsz = CAST_U32(updateFiles.size()); @@ -752,8 +756,8 @@ void UpdaterWindow::loadManaPlusUpdates(const std::string &dir) if (strStartWith(name, "manaplus_")) { struct stat statbuf; - std::string fileName = std::string(fixPath).append( - "/").append(name); + std::string fileName = pathJoin(fixPath, + name); if (!stat(fileName.c_str(), &statbuf)) { VirtFs::mountZip(fileName, @@ -767,7 +771,8 @@ void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir) { const std::string fixPath = dir + "/fix"; const std::vector<UpdateFile> updateFiles = loadXMLFile( - std::string(fixPath).append("/").append(xmlUpdateFile), true); + pathJoin(fixPath, xmlUpdateFile), + true); for (unsigned int updateIndex = 0, fsz = CAST_U32(updateFiles.size()); @@ -778,8 +783,8 @@ void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir) if (strStartWith(name, "manaplus_")) { struct stat statbuf; - const std::string file = std::string( - fixPath).append("/").append(name); + const std::string file = pathJoin( + fixPath, name); if (!stat(file.c_str(), &statbuf)) VirtFs::unmountZip(file); } @@ -791,11 +796,11 @@ void UpdaterWindow::addUpdateFile(const std::string &restrict path, const std::string &restrict file, const Append append) { - const std::string tmpPath = std::string(path).append("/").append(file); + const std::string tmpPath = pathJoin(path, file); if (append == Append_false) VirtFs::mountZip(tmpPath, append); - const std::string fixFile = std::string(fixPath).append("/").append(file); + const std::string fixFile = pathJoin(fixPath, file); struct stat statbuf; if (!stat(fixFile.c_str(), &statbuf)) VirtFs::mountZip(fixFile, append); @@ -808,9 +813,8 @@ void UpdaterWindow::removeUpdateFile(const std::string &restrict path, const std::string &restrict fixPath, const std::string &restrict file) { - VirtFs::unmountZip( - std::string(path).append("/").append(file)); - const std::string fixFile = std::string(fixPath).append("/").append(file); + VirtFs::unmountZip(pathJoin(path, file)); + const std::string fixFile = pathJoin(fixPath, file); struct stat statbuf; if (!stat(fixFile.c_str(), &statbuf)) VirtFs::unmountZip(fixFile); @@ -883,7 +887,7 @@ void UpdaterWindow::logic() loadPatch(); mUpdateHost = updateServer2 + mUpdateServerPath; - mUpdatesDir.append("/fix"); + mUpdatesDir = pathJoin(mUpdatesDir, "fix"); mCurrentFile = xmlUpdateFile; mValidateXml = true; mStoreInMemory = false; @@ -897,8 +901,9 @@ void UpdaterWindow::logic() { if (mCurrentFile == xmlUpdateFile) { - mUpdateFiles = loadXMLFile(std::string(mUpdatesDir).append( - "/").append(xmlUpdateFile), true); + mUpdateFiles = loadXMLFile(pathJoin( + mUpdatesDir, xmlUpdateFile), + true); if (mUpdateFiles.empty()) { @@ -920,8 +925,8 @@ void UpdaterWindow::logic() else if (mCurrentFile == txtUpdateFile) { mValidateXml = true; - mUpdateFiles = loadTxtFile(std::string(mUpdatesDir).append( - "/").append(txtUpdateFile)); + mUpdateFiles = loadTxtFile(pathJoin(mUpdatesDir, + txtUpdateFile)); } mStoreInMemory = false; mDownloadStatus = UpdateDownloadStatus::UPDATE_RESOURCES; @@ -945,12 +950,12 @@ void UpdaterWindow::logic() std::stringstream ss(checksum); ss >> std::hex >> mCurrentChecksum; - std::ifstream temp((std::string(mUpdatesDir).append( - "/").append(mCurrentFile)).c_str()); + std::ifstream temp(pathJoin(mUpdatesDir, + mCurrentFile).c_str()); mValidateXml = false; - if (!temp.is_open() || !validateFile(std::string( - mUpdatesDir).append("/").append(mCurrentFile), + if (!temp.is_open() || !validateFile(pathJoin( + mUpdatesDir, mCurrentFile), mCurrentChecksum)) { temp.close(); @@ -988,8 +993,9 @@ void UpdaterWindow::logic() { if (mCurrentFile == xmlUpdateFile) { - mTempUpdateFiles = loadXMLFile(std::string( - mUpdatesDir).append("/").append(xmlUpdateFile), true); + mTempUpdateFiles = loadXMLFile(pathJoin( + mUpdatesDir, xmlUpdateFile), + true); } mUpdateIndexOffset = mUpdateIndex; mUpdateIndex = 0; @@ -1013,11 +1019,11 @@ void UpdaterWindow::logic() std::stringstream ss(checksum); ss >> std::hex >> mCurrentChecksum; - std::ifstream temp((std::string(mUpdatesDir).append( - "/").append(mCurrentFile)).c_str()); + std::ifstream temp((pathJoin(mUpdatesDir, + mCurrentFile)).c_str()); - if (!temp.is_open() || !validateFile(std::string( - mUpdatesDir).append("/").append(mCurrentFile), + if (!temp.is_open() || !validateFile(pathJoin( + mUpdatesDir, mCurrentFile), mCurrentChecksum)) { temp.close(); @@ -1118,7 +1124,8 @@ void UpdaterWindow::loadMods(const std::string &dir, } std::vector<UpdateFile> updateFiles2 = loadXMLFile( - std::string(fixPath).append("/").append(xmlUpdateFile), true); + pathJoin(fixPath, xmlUpdateFile), + true); for (unsigned int updateIndex = 0, fsz = CAST_U32(updateFiles2.size()); @@ -1136,8 +1143,8 @@ void UpdaterWindow::loadMods(const std::string &dir, if (it != modsList.end()) { struct stat statbuf; - std::string fileName = std::string(fixPath).append( - "/").append(name); + std::string fileName = pathJoin(fixPath, + name); if (!stat(fileName.c_str(), &statbuf)) { VirtFs::mountZip(fileName, diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp index 8fddc0a19..7d9e47e8b 100644 --- a/src/resources/db/emotedb.cpp +++ b/src/resources/db/emotedb.cpp @@ -50,8 +50,8 @@ void EmoteDB::load() unload(); EmoteSprite *const unknownSprite = new EmoteSprite; - unknownSprite->sprite = AnimatedSprite::load(paths.getStringValue( - "sprites").append(paths.getStringValue( + unknownSprite->sprite = AnimatedSprite::load(pathJoin(paths.getStringValue( + "sprites"), paths.getStringValue( "spriteErrorFile"))); unknownSprite->name = "unknown"; unknownSprite->id = 0; @@ -126,9 +126,9 @@ void EmoteDB::loadXmlFile(const std::string &fileName, if (xmlNameEqual(spriteNode, "sprite")) { EmoteSprite *const currentSprite = new EmoteSprite; - currentSprite->sprite = AnimatedSprite::load( - paths.getStringValue("sprites").append(std::string( - XmlChildContent(spriteNode))), + currentSprite->sprite = AnimatedSprite::load(pathJoin( + paths.getStringValue("sprites"), + XmlChildContent(spriteNode)), XML::getProperty(spriteNode, "variant", 0)); currentSprite->name = XML::langProperty( spriteNode, "name", ""); @@ -199,9 +199,9 @@ void EmoteDB::loadSpecialXmlFile(const std::string &fileName, if (xmlNameEqual(spriteNode, "sprite")) { EmoteSprite *const currentSprite = new EmoteSprite; - currentSprite->sprite = AnimatedSprite::load( - paths.getStringValue("sprites").append(std::string( - XmlChildContent(spriteNode))), + currentSprite->sprite = AnimatedSprite::load(pathJoin( + paths.getStringValue("sprites"), + XmlChildContent(spriteNode)), XML::getProperty(spriteNode, "variant", 0)); currentSprite->name = XML::langProperty( spriteNode, "name", ""); diff --git a/src/resources/db/horsedb.cpp b/src/resources/db/horsedb.cpp index 1eab6ada7..a6b395d3f 100644 --- a/src/resources/db/horsedb.cpp +++ b/src/resources/db/horsedb.cpp @@ -43,8 +43,8 @@ namespace #define loadSprite(name) \ { \ SpriteReference *const currentSprite = new SpriteReference; \ - currentSprite->sprite = paths.getStringValue("sprites").append( \ - std::string(XmlChildContent(spriteNode))); \ + currentSprite->sprite = pathJoin(paths.getStringValue("sprites"), \ + XmlChildContent(spriteNode)); \ currentSprite->variant = XML::getProperty( \ spriteNode, "variant", 0); \ currentInfo->name.push_back(currentSprite); \ @@ -62,13 +62,13 @@ void HorseDB::load() unload(); SpriteReference *currentSprite = new SpriteReference; - currentSprite->sprite = paths.getStringValue("sprites").append( + currentSprite->sprite = pathJoin(paths.getStringValue("sprites"), paths.getStringValue("spriteErrorFile")); currentSprite->variant = 0; mUnknown.downSprites.push_back(currentSprite); currentSprite = new SpriteReference; - currentSprite->sprite = paths.getStringValue("sprites").append( + currentSprite->sprite = pathJoin(paths.getStringValue("sprites"), paths.getStringValue("spriteErrorFile")); currentSprite->variant = 0; mUnknown.upSprites.push_back(currentSprite); diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 6c0363e6c..75e166a0d 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -152,7 +152,8 @@ void ItemInfo::addSound(const ItemSoundEvent::Type event, const std::string &filename, const int delay) { mSounds[event].push_back(SoundInfo( - paths.getStringValue("sfx").append(filename), delay)); + pathJoin(paths.getStringValue("sfx"), filename), + delay)); } const SoundInfo &ItemInfo::getSound(const ItemSoundEvent::Type event) const diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index b7e5d1fca..c24e3752e 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -1135,8 +1135,8 @@ void Map::addExtraLayer() restrict2 BLOCK_END("Map::addExtraLayer") return; } - const std::string mapFileName = getUserMapDirectory().append( - "/extralayer.txt"); + const std::string mapFileName = pathJoin(getUserMapDirectory(), + "extralayer.txt"); logger->log("loading extra layer: " + mapFileName); struct stat statbuf; if (!stat(mapFileName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode)) @@ -1208,8 +1208,8 @@ void Map::saveExtraLayer() const restrict2 logger->log1("No special layer"); return; } - const std::string mapFileName = getUserMapDirectory().append( - "/extralayer.txt"); + const std::string mapFileName = pathJoin(getUserMapDirectory(), + "extralayer.txt"); logger->log("saving extra layer: " + mapFileName); if (mkdir_r(getUserMapDirectory().c_str())) diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 307364457..84dff3140 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -337,8 +337,8 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) const int tileh = XML::getProperty(node, "tileheight", -1); const bool showWarps = config.getBoolValue("warpParticle"); - const std::string warpPath = paths.getStringValue("particles") - .append(paths.getStringValue("portalEffectFile")); + const std::string warpPath = pathJoin(paths.getStringValue("particles"), + paths.getStringValue("portalEffectFile")); if (tilew < 0 || tileh < 0) { @@ -1280,7 +1280,7 @@ void MapReader::updateMusic(Map *const map) if (p != std::string::npos) name = name.substr(0, p); name.append(".ogg"); - if (VirtFs::exists(paths.getStringValue("music").append(name))) + if (VirtFs::exists(pathJoin(paths.getStringValue("music"), name))) map->setProperty("music", name); } diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp index 59ac9d9f4..2b79c3806 100644 --- a/src/resources/sprite/spritedef.cpp +++ b/src/resources/sprite/spritedef.cpp @@ -105,7 +105,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, { reportAlways("Error, failed to parse sprite %s", animationFile.c_str()); - const std::string errorFile = paths.getStringValue("sprites").append( + const std::string errorFile = pathJoin(paths.getStringValue("sprites"), paths.getStringValue("spriteErrorFile")); BLOCK_END("SpriteDef::load") doc->decRef(); diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 79cb6bbbd..9b12946d4 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -156,7 +156,7 @@ std::string Wallpaper::getWallpaper(const int width, const int height) // Return the backup file if everything else failed... if (haveBackup) - return std::string(wallpaperPath).append(wallpaperFile); + return pathJoin(wallpaperPath, wallpaperFile); // Return an empty string if everything else failed return std::string(); diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp index ba455f65f..7d085fff4 100644 --- a/src/soundmanager.cpp +++ b/src/soundmanager.cpp @@ -325,7 +325,8 @@ void SoundManager::setSfxVolume(const int volume) static SDLMusic *loadMusic(const std::string &fileName, const SkipError skipError) { - const std::string path = paths.getStringValue("music").append(fileName); + const std::string path = pathJoin(paths.getStringValue("music"), + fileName); if (!VirtFs::exists(path)) { if (skipError == SkipError_false) @@ -460,7 +461,7 @@ void SoundManager::playSfx(const std::string &path, } else { - tmpPath = paths.getValue("sfx", "sfx/").append(path); + tmpPath = pathJoin(paths.getValue("sfx", "sfx"), path); } SoundEffect *const sample = Loader::getSoundEffect(tmpPath); if (sample) @@ -493,8 +494,8 @@ void SoundManager::playGuiSound(const std::string &name) const std::string sound = config.getStringValue(name); if (sound == "(no sound)") return; - playGuiSfx(branding.getStringValue("systemsounds").append( - sound).append(".ogg")); + playGuiSfx(pathJoin(branding.getStringValue("systemsounds"), + std::string(sound).append(".ogg"))); } void SoundManager::playGuiSfx(const std::string &path) @@ -510,7 +511,7 @@ void SoundManager::playGuiSfx(const std::string &path) if (!path.compare(0, 4, "sfx/")) tmpPath = path; else - tmpPath = paths.getValue("sfx", "sfx/").append(path); + tmpPath = pathJoin(paths.getValue("sfx", "sfx"), path); SoundEffect *const sample = Loader::getSoundEffect(tmpPath); if (sample) { diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 5143086df..4a26fc78c 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -92,8 +92,8 @@ AnimatedSprite *StatusEffect::getIcon() const } else { - return AnimatedSprite::load(paths.getStringValue( - "sprites").append(mIcon)); + return AnimatedSprite::load(pathJoin(paths.getStringValue("sprites"), + mIcon)); } } |