Browse Source

- fixed Exist function on Linux

Alexander Wagner 1 năm trước cách đây
mục cha
commit
d03ab3ef27
1 tập tin đã thay đổi với 6 bổ sung4 xóa
  1. 6 4
      code/Common/DefaultIOSystem.cpp

+ 6 - 4
code/Common/DefaultIOSystem.cpp

@@ -99,12 +99,12 @@ bool DefaultIOSystem::Exists(const char *pFile) const {
         return false;
     }
 #else
-    FILE *file = ::fopen(pFile, "rb");
-    if (!file) {
+	struct stat statbuf;
+    stat(pFile, &statbuf);
+    // test for a regular file
+    if (!S_ISREG(statbuf.st_mode)){
         return false;
     }
-
-    ::fclose(file);
 #endif
 
     return true;
@@ -116,6 +116,7 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) {
     ai_assert(strFile != nullptr);
     ai_assert(strMode != nullptr);
     FILE *file;
+	
 #ifdef _WIN32
     std::wstring name = Utf8ToWide(strFile);
     if (name.empty()) {
@@ -126,6 +127,7 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) {
 #else
     file = ::fopen(strFile, strMode);
 #endif
+	
     if (!file) {
         return nullptr;
     }