From 2ac4af7560ae6596f442600843acc9fe9cfe7964 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 4 May 2017 17:43:11 +0300 Subject: Improve join some paths. --- src/fs/files.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/fs/files.cpp') diff --git a/src/fs/files.cpp b/src/fs/files.cpp index 3bb3262da..03b478cbe 100644 --- a/src/fs/files.cpp +++ b/src/fs/files.cpp @@ -47,7 +47,7 @@ void Files::extractLocale() const std::string fileName2 = pathJoin(getenv("APPDIR"), "locale.zip"); VirtFs::mountZip(fileName2, Append_false); - const std::string localDir = std::string(getenv("APPDIR")).append("/"); + const std::string localDir = std::string(getenv("APPDIR")); VirtList *const rootDirs = VirtFs::enumerateFiles("locale"); FOR_EACH (StringVectCIter, i, rootDirs->names) { @@ -57,8 +57,10 @@ void Files::extractLocale() const std::string moFile = dir + "/LC_MESSAGES/manaplus.mo"; if (VirtFs::exists((moFile))) { - const std::string localFile = localDir + moFile; - const std::string localDir2 = localDir + dir + "/LC_MESSAGES"; + const std::string localFile = pathJoin(localDir, moFile); + const std::string localDir2 = pathJoin(localDir, + dir, + "LC_MESSAGES"); mkdir_r(localDir2.c_str()); copyVirtFsFile(moFile, localFile); } @@ -273,7 +275,7 @@ void Files::saveTextFile(const std::string &path, void Files::deleteFilesInDirectory(std::string path) { - path += "/"; + path == pathJoin(path, dirSeparator); const struct dirent *next_file = nullptr; DIR *const dir = opendir(path.c_str()); @@ -293,8 +295,8 @@ void Files::enumFiles(StringVect &files, std::string path, const bool skipSymlinks A_WIN_UNUSED) { - if (findLast(path, "/") == false) - path += "/"; + if (findLast(path, dirSeparator) == false) + path += dirSeparator; const struct dirent *next_file = nullptr; DIR *const dir = opendir(path.c_str()); -- cgit v1.2.3-60-g2f50