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

When serializing to folder that doesn't exist, create it

Marko Pintera 11 лет назад
Родитель
Сommit
092593384f
1 измененных файлов с 5 добавлено и 0 удалено
  1. 5 0
      BansheeUtility/Source/BsFileSerializer.cpp

+ 5 - 0
BansheeUtility/Source/BsFileSerializer.cpp

@@ -4,6 +4,7 @@
 #include "BsIReflectable.h"
 #include "BsBinarySerializer.h"
 #include "BsPath.h"
+#include "BsFileSystem.h"
 
 #include <numeric>
 
@@ -23,6 +24,10 @@ namespace BansheeEngine
 
 	void FileSerializer::encode(IReflectable* object, const Path& fileLocation)
 	{
+		Path parentDir = fileLocation.getDirectory();
+		if (!FileSystem::exists(parentDir))
+			FileSystem::createDir(parentDir);
+
 		mOutputStream.open(fileLocation.toString().c_str(), std::ios::out | std::ios::binary);
 
 		BinarySerializer bs;