From 35ff05fe5c98a26581a9282730a0a624605b70e1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 15 Feb 2017 03:36:05 +0300 Subject: Add more unit tests for virtfs. Also add some testing files. --- src/utils/virtfstools.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/utils/virtfstools.cpp') diff --git a/src/utils/virtfstools.cpp b/src/utils/virtfstools.cpp index e4b4d02cf..adc1c9772 100644 --- a/src/utils/virtfstools.cpp +++ b/src/utils/virtfstools.cpp @@ -49,7 +49,7 @@ namespace VirtFs } logger->log("Loaded %s/%s", - VirtFs::getRealDir(fileName), + VirtFs::getRealDir(fileName).c_str(), fileName.c_str()); fileSize = CAST_S32(VirtFs::fileLength(file)); @@ -75,8 +75,7 @@ namespace VirtFs !ext.compare(str.substr(len - ext.length()))) { const std::string file = path + str; - const std::string realPath = std::string( - VirtFs::getRealDir(file)); + const std::string realPath = VirtFs::getRealDir(file); VirtFs::addZipToSearchPath(std::string(realPath).append( dirSeparator).append(file), append); } @@ -96,8 +95,7 @@ namespace VirtFs !ext.compare(str.substr(len - ext.length()))) { const std::string file = path + str; - const std::string realPath = std::string( - VirtFs::getRealDir(file)); + const std::string realPath = VirtFs::getRealDir(file); VirtFs::removeZipFromSearchPath(std::string( realPath).append( dirSeparator).append( @@ -141,7 +139,7 @@ namespace VirtFs VirtList *const fonts = VirtFs::enumerateFiles(path); FOR_EACH (StringVectCIter, i, fonts->names) { - if (!VirtFs::isDirectory(path + *i)) + if (!VirtFs::isDirectory(path + dirSeparator + *i)) list.push_back(*i); } VirtFs::freeList(fonts); @@ -152,7 +150,7 @@ namespace VirtFs VirtList *const fonts = VirtFs::enumerateFiles(path); FOR_EACH (StringVectCIter, i, fonts->names) { - if (VirtFs::isDirectory(path + *i)) + if (VirtFs::isDirectory(path + dirSeparator + *i)) list.push_back(*i); } VirtFs::freeList(fonts); @@ -161,11 +159,11 @@ namespace VirtFs std::string getPath(const std::string &file) { // get the real path to the file - const char *const tmp = VirtFs::getRealDir(file); + const std::string tmp = VirtFs::getRealDir(file); std::string path; - // if the file is not in the search path, then its nullptr - if (tmp) + // if the file is not in the search path, then its empty + if (!tmp.empty()) { path = std::string(tmp).append(dirSeparator).append(file); #if defined __native_client__ -- cgit v1.2.3-70-g09d2