diff options
author | Stijn Buys <ingar@osirion.org> | 2008-08-03 14:22:25 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-08-03 14:22:25 +0000 |
commit | d53bff0e774a179186d69a05e529cc29209ba4e0 (patch) | |
tree | 0788ae3504404d2d28a156b5d1b2a29e3169aa72 | |
parent | 38bfca98a4203130251b4848d1f4c0f0c3c28ff4 (diff) |
stat is called _stat on win32
-rw-r--r-- | src/sys/sys.cc | 22 |
1 files changed, 20 insertions, 2 deletions
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 <windows.h> +#include <sys/types.h> +#include <sys/stat.h> #else @@ -15,8 +17,8 @@ #include <signal.h> #include <string.h> #include <sys/time.h> -#include <sys/stat.h> #include <sys/types.h> +#include <sys/stat.h> #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) |