diff options
Diffstat (limited to 'src/gui/windows')
-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 |
6 files changed, 60 insertions, 54 deletions
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, |