Add gd::FileStream (#312)

* Fix unicode paths on Windows for XML files
* Add a fstream equivalent that supports gd::String paths (with characters outside the current codepage on Windows)
* Add a sf::InputStream subclass for the same purpose
* Use gd::FileStream in DatFile and ResourcesLoader
* Replace remaining i/ofstream with gd::FileStream
This commit is contained in:
Victor Levasseur
2016-11-13 16:24:11 +01:00
committed by Florian Rival
parent d6f3b2776e
commit 3b75fd6df4
22 changed files with 567 additions and 60 deletions
+3 -2
View File
@@ -5,6 +5,7 @@
*/
#include "GDCore/String.h"
#include "GDCore/Tools/FileStream.h"
#include <algorithm>
#include "AbstractFileSystem.h"
#include "GDCore/CommonTools.h"
@@ -108,7 +109,7 @@ gd::String NativeFileSystem::GetTempDir()
bool NativeFileSystem::WriteToFile(const gd::String & filename, const gd::String & content)
{
std::ofstream file( filename.ToLocale().c_str() );
gd::FileStream file( filename );
if ( file.is_open() ) {
file << content.ToUTF8();
file.close();
@@ -120,7 +121,7 @@ bool NativeFileSystem::WriteToFile(const gd::String & filename, const gd::String
gd::String NativeFileSystem::ReadFile(const gd::String & file)
{
std::ifstream t(file.ToLocale().c_str());
gd::FileStream t(file);
std::stringstream buffer;
buffer << t.rdbuf();
return gd::String::FromUTF8(buffer.str());