Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-02-08 13:12:41 +0000
committerStijn Buys <ingar@osirion.org>2009-02-08 13:12:41 +0000
commit43f7733dfdd8700430a238d230ed573c12e72c87 (patch)
treea3fd4dea40ae291ee8bed1dfb3472324e1657fe0 /src/sys/sys.cc
parent48892cf81a5ef06103286947b2eb55c7c46681a4 (diff)
added filesystem::FileStream
Diffstat (limited to 'src/sys/sys.cc')
-rw-r--r--src/sys/sys.cc33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/sys/sys.cc b/src/sys/sys.cc
index 59ed11d..01c9e3b 100644
--- a/src/sys/sys.cc
+++ b/src/sys/sys.cc
@@ -32,7 +32,38 @@
namespace sys
{
-bool isdirectory(const std::string &path)
+bool file_exists(const std::string &filename)
+{
+#ifdef _WIN32
+ struct ::_stat path_stat;
+ memset(&path_stat, 0, sizeof(struct ::_stat));
+
+ if (::_stat(filename.c_str(), &path_stat) != 0) {
+ return false;
+ }
+
+ if (path_stat.st_mode & _S_IFDIR) {
+ return false;
+ }
+ return true;
+#else
+ struct stat path_stat;
+ memset(&path_stat, 0, sizeof(path_stat));
+
+ if (stat(filename.c_str(), &path_stat) != 0) {
+ return false;
+ }
+
+ if (path_stat.st_mode & S_IFDIR) {
+ return false;
+ }
+
+ return true;
+#endif
+}
+
+
+bool directory_exists(const std::string &path)
{
#ifdef _WIN32
struct ::_stat path_stat;