From bbd71d4a8c95092deb9cbf4aef86722a1e9628db Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 7 Mar 2017 22:02:59 +0300 Subject: Fix unit tests on windows. --- src/fs/files.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/fs/files.cpp') diff --git a/src/fs/files.cpp b/src/fs/files.cpp index d8a6e76ec..f6a138475 100644 --- a/src/fs/files.cpp +++ b/src/fs/files.cpp @@ -38,6 +38,8 @@ #include "debug.h" +extern const char *dirSeparator; + #ifdef ANDROID void Files::extractLocale() { @@ -211,7 +213,21 @@ int Files::copyFile(const std::string &restrict srcName, bool Files::existsLocal(const std::string &path) { struct stat statbuf; +#ifdef WIN32 + // in windows path\file.ext\ by default detected as exists + // if file.ext is not directory, need return false + const bool res = (stat(path.c_str(), &statbuf) == 0); + if (res == false) + return false; + if ((findLast(path, "/") == true || findLast(path, "\\") == true) && + S_ISDIR(statbuf.st_mode) == 0) + { + return false; + } + return true; +#else // WIN32 return stat(path.c_str(), &statbuf) == 0; +#endif // WIN32 } bool Files::loadTextFileLocal(const std::string &fileName, -- cgit v1.2.3-60-g2f50