Implement FileSystem::exists().

This commit is contained in:
castano 2009-01-09 02:24:32 +00:00
parent 508f9fbdc2
commit 10de10b9c2

View File

@ -8,7 +8,7 @@
#else #else
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
//#include <unistd.h> #include <unistd.h>
#endif #endif
using namespace nv; using namespace nv;
@ -16,9 +16,17 @@ using namespace nv;
bool FileSystem::exists(const char * path) bool FileSystem::exists(const char * path)
{ {
// stat buf; #if NV_OS_UNIX
// stat(path, &buf); struct stat buf;
return false; 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) bool FileSystem::createDirectory(const char * path)
@ -29,3 +37,4 @@ bool FileSystem::createDirectory(const char * path)
return mkdir(path, 0777) != -1; return mkdir(path, 0777) != -1;
#endif #endif
} }