Make all fopen utf8 path aware

This commit is contained in:
Benau 2019-06-28 21:05:50 +08:00
parent ea8896bc17
commit 31caa7e056
8 changed files with 17 additions and 9 deletions

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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<std::string>* all_
std::string filename = *dir + "/" + *file;
FILE* f = fopen(filename.c_str(), "r");
FILE* f = FileUtils::fopenU8Path(filename, "r");
if (f)
{
fclose(f);

View File

@ -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.");
}

View File

@ -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)
{

View File

@ -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());
}

View File

@ -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());

View File

@ -20,6 +20,7 @@
#include "config/user_config.hpp"
#include "network/network_config.hpp"
#include "utils/file_utils.hpp"
#include <cstdio>
#include <ctime>
@ -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 "