Add unicode filepath support to replay class

This commit is contained in:
Benau
2019-06-28 20:59:44 +08:00
parent 324d2817f5
commit ea8896bc17
3 changed files with 7 additions and 5 deletions

View File

@@ -18,6 +18,7 @@
#include "replay/replay_base.hpp"
#include "io/file_manager.hpp"
#include "utils/file_utils.hpp"
// -----------------------------------------------------------------------------
ReplayBase::ReplayBase()
@@ -31,8 +32,8 @@ ReplayBase::ReplayBase()
*/
FILE* ReplayBase::openReplayFile(bool writeable, bool full_path, int replay_file_number)
{
FILE *fd = fopen(full_path ? getReplayFilename(replay_file_number).c_str() :
(file_manager->getReplayDir() + getReplayFilename(replay_file_number)).c_str(),
FILE* fd = FileUtils::fopenU8Path(full_path ? getReplayFilename(replay_file_number) :
file_manager->getReplayDir() + getReplayFilename(replay_file_number),
writeable ? "w" : "r");
if (!fd)
{

View File

@@ -26,6 +26,7 @@
#include "race/race_manager.hpp"
#include "tracks/track.hpp"
#include "tracks/track_manager.hpp"
#include "utils/file_utils.hpp"
#include "utils/string_utils.hpp"
#include <irrlicht.h>
@@ -108,8 +109,8 @@ bool ReplayPlay::addReplayFile(const std::string& fn, bool custom_replay, int ca
char s[1024], s1[1024];
if (StringUtils::getExtension(fn) != "replay") return false;
FILE *fd = fopen(custom_replay ? fn.c_str() :
(file_manager->getReplayDir() + fn).c_str(), "r");
FILE* fd = FileUtils::fopenU8Path(custom_replay ? fn :
file_manager->getReplayDir() + fn, "r");
if (fd == NULL) return false;
ReplayData rd;

View File

@@ -394,7 +394,7 @@ void ReplayRecorder::save()
}
core::stringw msg = _("Replay saved in \"%s\".",
(file_manager->getReplayDir() + getReplayFilename()).c_str());
StringUtils::utf8ToWide(file_manager->getReplayDir() + getReplayFilename()));
MessageQueue::add(MessageQueue::MT_GENERIC, msg);
fprintf(fd, "version: %d\n", getCurrentReplayVersion());