From d53bff0e774a179186d69a05e529cc29209ba4e0 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 3 Aug 2008 14:22:25 +0000 Subject: stat is called _stat on win32 --- src/sys/sys.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/sys') diff --git a/src/sys/sys.cc b/src/sys/sys.cc index 9526166..3aec456 100644 --- a/src/sys/sys.cc +++ b/src/sys/sys.cc @@ -8,6 +8,8 @@ #ifdef _WIN32 #include +#include +#include #else @@ -15,8 +17,8 @@ #include #include #include -#include #include +#include #endif @@ -29,16 +31,32 @@ namespace sys { bool isdirectory(std::string const &path) { +#ifdef _WIN32 + struct ::_stat path_stat; + memset(&path_stat, 0, sizeof(struct ::_stat)); + + if (::_stat(path.c_str(), &path_stat) != 0) { + return false; + } + + if (path_stat.st_mode & _S_IFDIR) { + return true; + } + return false; +#else struct stat path_stat; memset(&path_stat, 0, sizeof(path_stat)); - if (stat(path.c_str(), &path_stat) != 0) + + if (stat(path.c_str(), &path_stat) != 0) { return false; + } if (path_stat.st_mode & S_IFDIR) { return true; } return false; +#endif } void mkdir(std::string const &path) -- cgit v1.2.3