Просмотр исходного кода

Fixed FileSystem::open on Android when using WRITE.
It now writes to the SD card.

Darryl Gough 13 лет назад
Родитель
Сommit
68811b49c0
1 измененных файлов с 10 добавлено и 1 удалено
  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
         std::string fullPath(__resourcePath);
         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
     {