diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-14 22:41:07 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-02-14 22:41:07 +0300 |
commit | 56d6454ba617d1dcddbbaa21e2066a7db0caee75 (patch) | |
tree | 5012e55f393db2d62b40eb64142fa4317b16c571 /src/utils/files.cpp | |
parent | bdec92381ef60cd027292ed63e254e8de70028d9 (diff) | |
download | manaplus-56d6454ba617d1dcddbbaa21e2066a7db0caee75.tar.gz manaplus-56d6454ba617d1dcddbbaa21e2066a7db0caee75.tar.bz2 manaplus-56d6454ba617d1dcddbbaa21e2066a7db0caee75.tar.xz manaplus-56d6454ba617d1dcddbbaa21e2066a7db0caee75.zip |
Move some virtfs replated functions from files.cpp into virtfstools.cpp
Diffstat (limited to 'src/utils/files.cpp')
-rw-r--r-- | src/utils/files.cpp | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/src/utils/files.cpp b/src/utils/files.cpp index b2cba4c52..87c1b7b0b 100644 --- a/src/utils/files.cpp +++ b/src/utils/files.cpp @@ -209,39 +209,6 @@ int Files::copyFile(const std::string &restrict srcName, return 0; } -void Files::getFiles(const std::string &path, StringVect &list) -{ - VirtList *const fonts = VirtFs::enumerateFiles(path); - FOR_EACH (StringVectCIter, i, fonts->names) - { - if (!VirtFs::isDirectory(path + *i)) - list.push_back(*i); - } - VirtFs::freeList(fonts); -} - -void Files::getDirs(const std::string &path, StringVect &list) -{ - VirtList *const fonts = VirtFs::enumerateFiles(path); - FOR_EACH (StringVectCIter, i, fonts->names) - { - if (VirtFs::isDirectory(path + *i)) - list.push_back(*i); - } - VirtFs::freeList(fonts); -} - -void Files::getFilesWithDir(const std::string &path, StringVect &list) -{ - VirtList *const fonts = VirtFs::enumerateFiles(path); - FOR_EACH (StringVectCIter, i, fonts->names) - { - if (!VirtFs::isDirectory(path + *i)) - list.push_back(path + *i); - } - VirtFs::freeList(fonts); -} - bool Files::existsLocal(const std::string &path) { bool flg(false); @@ -253,70 +220,6 @@ bool Files::existsLocal(const std::string &path) return flg; } -std::string Files::getPath(const std::string &file) -{ - // get the real path to the file - const char *const tmp = VirtFs::getRealDir(file); - std::string path; - - // if the file is not in the search path, then its nullptr - if (tmp) - { - path = std::string(tmp).append(dirSeparator).append(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 = getPackageDir().append(dirSeparator).append(file); - } - - return path; -} - -std::string Files::loadTextFileString(const std::string &fileName) -{ - int contentsLength; - char *fileContents = static_cast<char*>( - 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); - free(fileContents); - return str; -} - -bool Files::loadTextFile(const std::string &fileName, - StringVect &lines) -{ - int contentsLength; - char *fileContents = static_cast<char*>( - 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); - - free(fileContents); - return true; -} - bool Files::loadTextFileLocal(const std::string &fileName, StringVect &lines) { @@ -368,19 +271,3 @@ void Files::deleteFilesInDirectory(std::string path) closedir(dir); } } - -void Files::getFilesInDir(const std::string &dir, - StringVect &list, - const std::string &ext) -{ - const std::string path = dir + "/"; - StringVect tempList; - Files::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()); -} |