@@ -92,12 +92,12 @@ bool InputManager::load(size_t player_index, std::string_view filename)
92
92
93
93
try
94
94
{
95
- std::ifstream file (file_path);
96
- if (!file. is_open ())
95
+ auto xmlData = FileStream::LoadIntoMemory (file_path);
96
+ if (!xmlData || xmlData-> empty ())
97
97
return false ;
98
-
98
+
99
99
pugi::xml_document doc;
100
- if (!doc.load (file ))
100
+ if (!doc.load_buffer (xmlData-> data (), xmlData-> size () ))
101
101
return false ;
102
102
103
103
const pugi::xml_node root = doc.document_element ();
@@ -216,12 +216,15 @@ bool InputManager::migrate_config(const fs::path& file_path)
216
216
{
217
217
try
218
218
{
219
- std::ifstream file (file_path);
220
- if (!file. is_open ())
219
+ auto xmlData = FileStream::LoadIntoMemory (file_path);
220
+ if (!xmlData || xmlData-> empty ())
221
221
return false ;
222
222
223
+ std::string iniDataStr ((const char *)xmlData->data (), xmlData->size ());
224
+
225
+ std::stringstream iniData (iniDataStr);
223
226
boost::property_tree::ptree m_data;
224
- read_ini (file , m_data);
227
+ read_ini (iniData , m_data);
225
228
226
229
const auto emulate_string = m_data.get <std::string>(" General.emulate" );
227
230
const auto api_string = m_data.get <std::string>(" General.api" );
@@ -455,7 +458,7 @@ bool InputManager::save(size_t player_index, std::string_view filename)
455
458
if (is_default_file)
456
459
file_path /= fmt::format (" controller{}" , player_index);
457
460
else
458
- file_path /= filename;
461
+ file_path /= _utf8ToPath ( filename) ;
459
462
460
463
file_path.replace_extension (" .xml" ); // force .xml extension
461
464
@@ -540,15 +543,15 @@ bool InputManager::save(size_t player_index, std::string_view filename)
540
543
}
541
544
}
542
545
}
543
-
544
-
545
- std::ofstream file (file_path, std::ios::out | std::ios:: trunc ) ;
546
- if (file. is_open ())
547
- {
548
- doc. save (file );
549
- return true ;
550
- }
551
- return false ;
546
+ FileStream* fs = FileStream::createFile2 (file_path);
547
+ if (!fs)
548
+ return false ;
549
+ std::stringstream xmlData;
550
+ doc. save (xmlData);
551
+ std::string xmlStr = xmlData. str ( );
552
+ fs-> writeData (xmlStr. data (), xmlStr. size ()) ;
553
+ delete fs;
554
+ return true ;
552
555
}
553
556
554
557
bool InputManager::is_gameprofile_set (size_t player_index) const
@@ -792,7 +795,7 @@ std::vector<std::string> InputManager::get_profiles()
792
795
const auto & p = entry.path ();
793
796
if (p.has_extension () && (p.extension () == " .xml" || p.extension () == " .txt" ))
794
797
{
795
- auto stem = p.filename ().stem (). string ( );
798
+ auto stem = _pathToUtf8 ( p.filename ().stem ());
796
799
if (is_valid_profilename (stem))
797
800
{
798
801
tmp.emplace (stem);
@@ -808,7 +811,7 @@ std::vector<std::string> InputManager::get_profiles()
808
811
809
812
bool InputManager::is_valid_profilename (const std::string& name)
810
813
{
811
- if (!boost::filesystem::windows_name (name))
814
+ if (!IsValidFilename (name))
812
815
return false ;
813
816
814
817
// dont allow default profile names
0 commit comments