From 3b3b53d96317b8ea4dceca2a6c7955737e6767d4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 5 May 2017 16:42:50 +0300 Subject: Rename virtfstools into tools. --- src/CMakeLists.txt | 8 +- src/Makefile.am | 4 +- src/client.cpp | 2 +- src/dyetool/client.cpp | 2 +- src/fs/files.cpp | 2 +- src/fs/files_unittest.cc | 2 +- src/fs/virtfs/tools.cpp | 156 ++++++++++++++++++++++++++++++++++ src/fs/virtfs/tools.h | 46 ++++++++++ src/fs/virtfs/virtfstools.cpp | 156 ---------------------------------- src/fs/virtfs/virtfstools.h | 46 ---------- src/gui/fonts/font.cpp | 2 +- src/gui/windowmanager.cpp | 2 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/helpwindow.cpp | 2 +- src/render/shaders/shadersmanager.cpp | 2 +- src/resources/beingcommon.h | 2 +- src/resources/db/badgesdb.cpp | 2 +- src/resources/db/itemdb.cpp | 2 +- src/resources/db/palettedb.cpp | 2 +- 19 files changed, 221 insertions(+), 221 deletions(-) create mode 100644 src/fs/virtfs/tools.cpp create mode 100644 src/fs/virtfs/tools.h delete mode 100644 src/fs/virtfs/virtfstools.cpp delete mode 100644 src/fs/virtfs/virtfstools.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index def79d5a9..c62b11eba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -893,8 +893,8 @@ SET(SRCS fs/virtfs/fsfuncs.h fs/virtfs/virtfsrwops.cpp fs/virtfs/virtfsrwops.h - fs/virtfs/virtfstools.cpp - fs/virtfs/virtfstools.h + fs/virtfs/tools.cpp + fs/virtfs/tools.h fs/virtfs/virtlist.cpp fs/virtfs/virtlist.h fs/virtfs/virtfs.cpp @@ -1802,8 +1802,8 @@ SET(DYE_CMD_SRCS fs/virtfs/fsfuncs.h fs/virtfs/virtfsrwops.cpp fs/virtfs/virtfsrwops.h - fs/virtfs/virtfstools.cpp - fs/virtfs/virtfstools.h + fs/virtfs/tools.cpp + fs/virtfs/tools.h fs/virtfs/virtlist.cpp fs/virtfs/virtlist.h fs/virtfs/virtfs.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 706bee1b0..9684fab6b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -581,8 +581,8 @@ BASE_SRC += events/actionevent.h \ fs/virtfs/fsfuncs.h \ fs/virtfs/virtfsrwops.cpp \ fs/virtfs/virtfsrwops.h \ - fs/virtfs/virtfstools.cpp \ - fs/virtfs/virtfstools.h \ + fs/virtfs/tools.cpp \ + fs/virtfs/tools.h \ fs/virtfs/virtlist.cpp \ fs/virtfs/virtlist.h \ utils/process.cpp \ diff --git a/src/client.cpp b/src/client.cpp index 21ea23ce1..a47d68098 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -43,7 +43,7 @@ #include "enums/being/attributesstrings.h" #include "fs/virtfs/virtfs.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "gui/dialogsmanager.h" #include "gui/gui.h" diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp index 0815272d4..9c33b2edd 100644 --- a/src/dyetool/client.cpp +++ b/src/dyetool/client.cpp @@ -31,7 +31,7 @@ #include "soundmanager.h" #include "fs/virtfs/virtfs.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "gui/dialogsmanager.h" #include "gui/gui.h" diff --git a/src/fs/files.cpp b/src/fs/files.cpp index 320e7e2d7..e805a5f1a 100644 --- a/src/fs/files.cpp +++ b/src/fs/files.cpp @@ -25,7 +25,7 @@ #include "fs/paths.h" #include "fs/virtfs/virtfs.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "fs/virtfs/virtlist.h" #endif // defined(ANDROID) || defined(__native_client__) diff --git a/src/fs/files_unittest.cc b/src/fs/files_unittest.cc index f44cadb7b..be3cf9256 100644 --- a/src/fs/files_unittest.cc +++ b/src/fs/files_unittest.cc @@ -24,7 +24,7 @@ #include "logger.h" #include "fs/virtfs/virtfs.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "utils/delete2.h" #include "utils/stringutils.h" diff --git a/src/fs/virtfs/tools.cpp b/src/fs/virtfs/tools.cpp new file mode 100644 index 000000000..6573e6141 --- /dev/null +++ b/src/fs/virtfs/tools.cpp @@ -0,0 +1,156 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013-2017 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "fs/virtfs/tools.h" + +#include "logger.h" + +#include "fs/paths.h" + +#include "fs/virtfs/virtfs.h" +#include "fs/virtfs/virtlist.h" + +#include "utils/stringutils.h" + +#include +#include + +#include "debug.h" + +namespace VirtFs +{ + void searchAndAddArchives(const std::string &restrict path, + const std::string &restrict ext, + const Append append) + { + VirtList *const list = VirtFs::enumerateFiles(path); + FOR_EACH (StringVectCIter, i, list->names) + { + const std::string str = *i; + const size_t len = str.size(); + + if (len > ext.length() && + !ext.compare(str.substr(len - ext.length()))) + { + const std::string file = path + str; + const std::string realPath = VirtFs::getRealDir(file); + VirtFs::mountZip(pathJoin(realPath, file), append); + } + } + VirtFs::freeList(list); + } + + void searchAndRemoveArchives(const std::string &restrict path, + const std::string &restrict ext) + { + VirtList *const list = VirtFs::enumerateFiles(path); + FOR_EACH (StringVectCIter, i, list->names) + { + const std::string str = *i; + const size_t len = str.size(); + if (len > ext.length() && + !ext.compare(str.substr(len - ext.length()))) + { + const std::string file = path + str; + const std::string realPath = VirtFs::getRealDir(file); + VirtFs::unmountZip(pathJoin(realPath, file)); + } + } + VirtFs::freeList(list); + } + + void getFilesInDir(const std::string &dir, + StringVect &list, + const std::string &ext) + { + const std::string path = dir; + StringVect tempList; + VirtFs::getFilesWithDir(path, tempList); + FOR_EACH (StringVectCIter, it, tempList) + { + const std::string &str = *it; + if (findLast(str, ext)) + list.push_back(str); + } + std::sort(list.begin(), list.end()); + } + + std::string getPath(const std::string &file) + { + // get the real path to the file + const std::string tmp = VirtFs::getRealDir(file); + std::string path; + + // if the file is not in the search path, then its empty + if (!tmp.empty()) + { + path = pathJoin(tmp, file); +#if defined __native_client__ + std::string dataZip = "/http/data.zip/"; + if (path.substr(0, dataZip.length()) == dataZip) + path = path.replace(0, dataZip.length(), "/http/data/"); +#endif // defined __native_client__ + } + else + { + // if not found in search path return the default path + path = pathJoin(getPackageDir(), file); + } + + return path; + } + + std::string loadTextFileString(const std::string &fileName) + { + int contentsLength; + const char *fileContents = VirtFs::loadFile(fileName, contentsLength); + + if (!fileContents) + { + logger->log("Couldn't load text file: %s", fileName.c_str()); + return std::string(); + } + const std::string str = std::string(fileContents, contentsLength); + delete [] fileContents; + return str; + } + + bool loadTextFile(const std::string &fileName, + StringVect &lines) + { + int contentsLength; + const char *fileContents = VirtFs::loadFile(fileName, contentsLength); + + if (!fileContents) + { + logger->log("Couldn't load text file: %s", fileName.c_str()); + return false; + } + + std::istringstream iss(std::string(fileContents, contentsLength)); + std::string line; + + while (getline(iss, line)) + lines.push_back(line); + + delete [] fileContents; + return true; + } +} // namespace VirtFs diff --git a/src/fs/virtfs/tools.h b/src/fs/virtfs/tools.h new file mode 100644 index 000000000..f00a976bb --- /dev/null +++ b/src/fs/virtfs/tools.h @@ -0,0 +1,46 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013-2017 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UTILS_VIRTFSTOOLS_H +#define UTILS_VIRTFSTOOLS_H + +#include "enums/simpletypes/append.h" + +#include "utils/stringvector.h" + +#include "localconsts.h" + +namespace VirtFs +{ + void searchAndAddArchives(const std::string &restrict path, + const std::string &restrict ext, + const Append append); + void searchAndRemoveArchives(const std::string &restrict path, + const std::string &restrict ext); + void getFilesInDir(const std::string &dir, + StringVect &list, + const std::string &ext); + std::string getPath(const std::string &file); + bool loadTextFile(const std::string &fileName, + StringVect &lines); + std::string loadTextFileString(const std::string &fileName); +} // namespace VirtFs + +#endif // UTILS_VIRTFSTOOLS_H diff --git a/src/fs/virtfs/virtfstools.cpp b/src/fs/virtfs/virtfstools.cpp deleted file mode 100644 index af44b34e8..000000000 --- a/src/fs/virtfs/virtfstools.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "fs/virtfs/virtfstools.h" - -#include "logger.h" - -#include "fs/paths.h" - -#include "fs/virtfs/virtfs.h" -#include "fs/virtfs/virtlist.h" - -#include "utils/stringutils.h" - -#include -#include - -#include "debug.h" - -namespace VirtFs -{ - void searchAndAddArchives(const std::string &restrict path, - const std::string &restrict ext, - const Append append) - { - VirtList *const list = VirtFs::enumerateFiles(path); - FOR_EACH (StringVectCIter, i, list->names) - { - const std::string str = *i; - const size_t len = str.size(); - - if (len > ext.length() && - !ext.compare(str.substr(len - ext.length()))) - { - const std::string file = path + str; - const std::string realPath = VirtFs::getRealDir(file); - VirtFs::mountZip(pathJoin(realPath, file), append); - } - } - VirtFs::freeList(list); - } - - void searchAndRemoveArchives(const std::string &restrict path, - const std::string &restrict ext) - { - VirtList *const list = VirtFs::enumerateFiles(path); - FOR_EACH (StringVectCIter, i, list->names) - { - const std::string str = *i; - const size_t len = str.size(); - if (len > ext.length() && - !ext.compare(str.substr(len - ext.length()))) - { - const std::string file = path + str; - const std::string realPath = VirtFs::getRealDir(file); - VirtFs::unmountZip(pathJoin(realPath, file)); - } - } - VirtFs::freeList(list); - } - - void getFilesInDir(const std::string &dir, - StringVect &list, - const std::string &ext) - { - const std::string path = dir; - StringVect tempList; - VirtFs::getFilesWithDir(path, tempList); - FOR_EACH (StringVectCIter, it, tempList) - { - const std::string &str = *it; - if (findLast(str, ext)) - list.push_back(str); - } - std::sort(list.begin(), list.end()); - } - - std::string getPath(const std::string &file) - { - // get the real path to the file - const std::string tmp = VirtFs::getRealDir(file); - std::string path; - - // if the file is not in the search path, then its empty - if (!tmp.empty()) - { - path = pathJoin(tmp, file); -#if defined __native_client__ - std::string dataZip = "/http/data.zip/"; - if (path.substr(0, dataZip.length()) == dataZip) - path = path.replace(0, dataZip.length(), "/http/data/"); -#endif // defined __native_client__ - } - else - { - // if not found in search path return the default path - path = pathJoin(getPackageDir(), file); - } - - return path; - } - - std::string loadTextFileString(const std::string &fileName) - { - int contentsLength; - const char *fileContents = VirtFs::loadFile(fileName, contentsLength); - - if (!fileContents) - { - logger->log("Couldn't load text file: %s", fileName.c_str()); - return std::string(); - } - const std::string str = std::string(fileContents, contentsLength); - delete [] fileContents; - return str; - } - - bool loadTextFile(const std::string &fileName, - StringVect &lines) - { - int contentsLength; - const char *fileContents = VirtFs::loadFile(fileName, contentsLength); - - if (!fileContents) - { - logger->log("Couldn't load text file: %s", fileName.c_str()); - return false; - } - - std::istringstream iss(std::string(fileContents, contentsLength)); - std::string line; - - while (getline(iss, line)) - lines.push_back(line); - - delete [] fileContents; - return true; - } -} // namespace VirtFs diff --git a/src/fs/virtfs/virtfstools.h b/src/fs/virtfs/virtfstools.h deleted file mode 100644 index f00a976bb..000000000 --- a/src/fs/virtfs/virtfstools.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef UTILS_VIRTFSTOOLS_H -#define UTILS_VIRTFSTOOLS_H - -#include "enums/simpletypes/append.h" - -#include "utils/stringvector.h" - -#include "localconsts.h" - -namespace VirtFs -{ - void searchAndAddArchives(const std::string &restrict path, - const std::string &restrict ext, - const Append append); - void searchAndRemoveArchives(const std::string &restrict path, - const std::string &restrict ext); - void getFilesInDir(const std::string &dir, - StringVect &list, - const std::string &ext); - std::string getPath(const std::string &file); - bool loadTextFile(const std::string &fileName, - StringVect &lines); - std::string loadTextFileString(const std::string &fileName); -} // namespace VirtFs - -#endif // UTILS_VIRTFSTOOLS_H diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp index c4af92717..70adce617 100644 --- a/src/gui/fonts/font.cpp +++ b/src/gui/fonts/font.cpp @@ -69,7 +69,7 @@ #include "fs/files.h" #include "fs/paths.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "gui/fonts/textchunk.h" diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp index 20e2f0b8b..ffc3e6593 100644 --- a/src/gui/windowmanager.cpp +++ b/src/gui/windowmanager.cpp @@ -29,7 +29,7 @@ #include "settings.h" #include "spellmanager.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "gui/gui.h" #include "gui/userpalette.h" diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 0b58b88fc..1e10c08bb 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -35,7 +35,7 @@ #include "const/gui/chat.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "input/inputmanager.h" diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index d0aa30b42..226284a35 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -28,7 +28,7 @@ #include "fs/paths.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "gui/gui.h" diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp index 8b0d89269..1180ae880 100644 --- a/src/render/shaders/shadersmanager.cpp +++ b/src/render/shaders/shadersmanager.cpp @@ -25,7 +25,7 @@ #include "configuration.h" #include "logger.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "render/opengl/mgl.h" #ifdef __native_client__ diff --git a/src/resources/beingcommon.h b/src/resources/beingcommon.h index caa1f4c9a..4299d7707 100644 --- a/src/resources/beingcommon.h +++ b/src/resources/beingcommon.h @@ -21,7 +21,7 @@ #ifndef RESOURCES_BEINGCOMMON_H #define RESOURCES_BEINGCOMMON_H -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "utils/xml.h" diff --git a/src/resources/db/badgesdb.cpp b/src/resources/db/badgesdb.cpp index f4939ca17..4b6bd85d2 100644 --- a/src/resources/db/badgesdb.cpp +++ b/src/resources/db/badgesdb.cpp @@ -22,7 +22,7 @@ #include "configuration.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "utils/xmlutils.h" diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index 12615a1a1..4bd68c42e 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -28,7 +28,7 @@ #include "enums/resources/spritedirection.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "resources/iteminfo.h" #include "resources/itemtypemapdata.h" diff --git a/src/resources/db/palettedb.cpp b/src/resources/db/palettedb.cpp index 90354b2fe..f6f54a875 100644 --- a/src/resources/db/palettedb.cpp +++ b/src/resources/db/palettedb.cpp @@ -22,7 +22,7 @@ #include "configuration.h" -#include "fs/virtfs/virtfstools.h" +#include "fs/virtfs/tools.h" #include "utils/checkutils.h" -- cgit v1.2.3-60-g2f50