mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-23 02:25:52 -04:00
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:
committed by
Florian Rival
parent
d6f3b2776e
commit
3b75fd6df4
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user