From 10de10b9c21d37bba06c10e062d2c0f3d755577a Mon Sep 17 00:00:00 2001 From: castano Date: Fri, 9 Jan 2009 02:24:32 +0000 Subject: [PATCH] Implement FileSystem::exists(). --- src/nvcore/FileSystem.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/nvcore/FileSystem.cpp b/src/nvcore/FileSystem.cpp index d3ce3f9..b582fe6 100644 --- a/src/nvcore/FileSystem.cpp +++ b/src/nvcore/FileSystem.cpp @@ -8,7 +8,7 @@ #else #include #include -//#include +#include #endif using namespace nv; @@ -16,9 +16,17 @@ using namespace nv; bool FileSystem::exists(const char * path) { -// stat buf; -// stat(path, &buf); - return false; +#if NV_OS_UNIX + struct stat buf; + return stat(path, &buf) == 0; +#else + if (FILE * fp = fopen(path, "r")) + { + fclose(fp); + return true; + } + return false; +#endif } bool FileSystem::createDirectory(const char * path) @@ -29,3 +37,4 @@ bool FileSystem::createDirectory(const char * path) return mkdir(path, 0777) != -1; #endif } +