diff --git a/src/audio/music_ogg.cpp b/src/audio/music_ogg.cpp index 4ec5840da..2d27a2cac 100644 --- a/src/audio/music_ogg.cpp +++ b/src/audio/music_ogg.cpp @@ -30,6 +30,7 @@ #include "audio/music_manager.hpp" #include "audio/sfx_manager.hpp" #include "utils/constants.hpp" +#include "utils/file_utils.hpp" #include "utils/log.hpp" MusicOggStream::MusicOggStream(float loop_start) @@ -58,7 +59,7 @@ bool MusicOggStream::load(const std::string& filename) m_fileName = filename; if(m_fileName=="") return false; - m_oggFile = fopen(m_fileName.c_str(), "rb"); + m_oggFile = FileUtils::fopenU8Path(m_fileName, "rb"); if(!m_oggFile) { diff --git a/src/audio/sfx_buffer.cpp b/src/audio/sfx_buffer.cpp index febc4bba2..756563f49 100644 --- a/src/audio/sfx_buffer.cpp +++ b/src/audio/sfx_buffer.cpp @@ -21,6 +21,7 @@ #include "config/user_config.hpp" #include "io/file_manager.hpp" #include "utils/constants.hpp" +#include "utils/file_utils.hpp" #include "utils/log.hpp" #ifdef ENABLE_SOUND @@ -171,7 +172,7 @@ bool SFXBuffer::loadVorbisBuffer(const std::string &name, ALuint buffer) return false; } - file = fopen(name.c_str(), "rb"); + file = FileUtils::fopenU8Path(name, "rb"); if(!file) { diff --git a/src/challenges/unlock_manager.cpp b/src/challenges/unlock_manager.cpp index b6ba2d93f..e1c743d46 100644 --- a/src/challenges/unlock_manager.cpp +++ b/src/challenges/unlock_manager.cpp @@ -31,6 +31,7 @@ #include "karts/kart_properties_manager.hpp" #include "race/race_manager.hpp" #include "tracks/track_manager.hpp" +#include "utils/file_utils.hpp" #include "utils/log.hpp" #include "utils/string_utils.hpp" @@ -109,7 +110,7 @@ void UnlockManager::readAllChallengesInDirs(const std::vector* all_ std::string filename = *dir + "/" + *file; - FILE* f = fopen(filename.c_str(), "r"); + FILE* f = FileUtils::fopenU8Path(filename, "r"); if (f) { fclose(f); diff --git a/src/network/network.cpp b/src/network/network.cpp index f64e3c771..cf8441d24 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -23,6 +23,7 @@ #include "network/network_config.hpp" #include "network/network_string.hpp" #include "network/transport_address.hpp" +#include "utils/file_utils.hpp" #include "utils/log.hpp" #include "utils/time.hpp" @@ -198,7 +199,7 @@ void Network::openLog() { std::string s = file_manager ->getUserConfigFile(FileManager::getStdoutName()+".packet"); - m_log_file.setAtomic(fopen(s.c_str(), "w+")); + m_log_file.setAtomic(FileUtils::fopenU8Path(s, "w+")); if (!m_log_file.getData()) Log::warn("STKHost", "Network packets won't be logged: no file."); } diff --git a/src/online/http_request.cpp b/src/online/http_request.cpp index 5fcb9d684..bd9fef00a 100644 --- a/src/online/http_request.cpp +++ b/src/online/http_request.cpp @@ -21,6 +21,7 @@ #include "io/file_manager.hpp" #include "online/request_manager.hpp" #include "utils/constants.hpp" +#include "utils/file_utils.hpp" #include "utils/translation.hpp" #ifdef WIN32 @@ -210,7 +211,7 @@ namespace Online FILE *fout = NULL; if (m_filename.size() > 0) { - fout = fopen((m_filename+".part").c_str(), "wb"); + fout = FileUtils::fopenU8Path(m_filename + ".part", "wb"); if (!fout) { diff --git a/src/race/history.cpp b/src/race/history.cpp index b2f51d17d..7f838496c 100644 --- a/src/race/history.cpp +++ b/src/race/history.cpp @@ -30,6 +30,7 @@ #include "race/race_manager.hpp" #include "tracks/track.hpp" #include "utils/constants.hpp" +#include "utils/file_utils.hpp" History* history = 0; bool History::m_online_history_replay = false; @@ -137,7 +138,7 @@ void History::Save() else { std::string fn = file_manager->getUserConfigFile("history.dat"); - fd = fopen(fn.c_str(), "w"); + fd = FileUtils::fopenU8Path(fn, "w"); if(fd) Log::info("History", "Saved in '%s'.", fn.c_str()); } @@ -196,7 +197,7 @@ void History::Load() else { std::string fn = file_manager->getUserConfigFile("history.dat"); - fd = fopen(fn.c_str(), "r"); + fd = FileUtils::fopenU8Path(fn, "r"); if(fd) Log::info("History", "Reading '%s'.", fn.c_str()); } diff --git a/src/scriptengine/script_engine.cpp b/src/scriptengine/script_engine.cpp index 72236ea05..1085fc66f 100644 --- a/src/scriptengine/script_engine.cpp +++ b/src/scriptengine/script_engine.cpp @@ -37,6 +37,7 @@ #include "states_screens/dialogs/tutorial_message_dialog.hpp" #include "tracks/track_object_manager.hpp" #include "tracks/track.hpp" +#include "utils/file_utils.hpp" #include "utils/profiler.hpp" @@ -94,7 +95,7 @@ namespace Scripting { //std::string script_path = World::getWorld()->getTrack()->getTrackFile(fileName); - FILE *f = fopen(script_path.c_str(), "rb"); + FILE *f = FileUtils::fopenU8Path(script_path, "rb"); if (f == NULL) { Log::debug("Scripting", "File does not exist : %s", script_path.c_str()); diff --git a/src/utils/log.cpp b/src/utils/log.cpp index 34b123761..615fffdde 100644 --- a/src/utils/log.cpp +++ b/src/utils/log.cpp @@ -20,6 +20,7 @@ #include "config/user_config.hpp" #include "network/network_config.hpp" +#include "utils/file_utils.hpp" #include #include @@ -293,7 +294,7 @@ void Log::flushBuffers() */ void Log::openOutputFiles(const std::string &logout) { - m_file_stdout = fopen(logout.c_str(), "w"); + m_file_stdout = FileUtils::fopenU8Path(logout, "w"); if (!m_file_stdout) { Log::error("main", "Can not open log file '%s'. Writing to "