summaryrefslogtreecommitdiff
path: root/src/fs/files.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-07 22:02:59 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-07 22:02:59 +0300
commitbbd71d4a8c95092deb9cbf4aef86722a1e9628db (patch)
tree59566c4baa2e32287fe5867e5616ca560d3f3bf5 /src/fs/files.cpp
parent6f7f469430ea05946a11dd41f62010961be6285e (diff)
downloadmanaverse-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.gz
manaverse-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.bz2
manaverse-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.xz
manaverse-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.zip
Fix unit tests on windows.
Diffstat (limited to 'src/fs/files.cpp')
-rw-r--r--src/fs/files.cpp16
1 files changed, 16 insertions, 0 deletions
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,