Browse Source

Merge pull request #626 from dgough/next

Fixed FileSystem::open on Android when using WRITE
Sean Paul Taylor 13 năm trước cách đây
mục cha
commit
e79765feb8
1 tập tin đã thay đổi với 10 bổ sung1 xóa
  1. 10 1
      gameplay/src/FileSystem.cpp

+ 10 - 1
gameplay/src/FileSystem.cpp

@@ -335,7 +335,16 @@ Stream* FileSystem::open(const char* path, size_t mode)
         // Open a file on the SD card
         // Open a file on the SD card
         std::string fullPath(__resourcePath);
         std::string fullPath(__resourcePath);
         fullPath += resolvePath(path);
         fullPath += resolvePath(path);
-        return FileStreamAndroid::create(fullPath.c_str(), modeStr);
+
+        size_t index = fullPath.rfind('/');
+        if (index != std::string::npos)
+        {
+            std::string directoryPath = fullPath.substr(0, index);
+            struct stat s;
+            if (stat(directoryPath.c_str(), &s) != 0)
+                makepath(directoryPath, 0777);
+        }
+        return FileStream::create(fullPath.c_str(), modeStr);
     }
     }
     else
     else
     {
     {