mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2025-02-28 15:30:32 +01:00
Force utf8 string conversion when constructing a nowide file stream
This commit is contained in:
parent
c4c5b2a848
commit
c65b071f68
@ -13,6 +13,7 @@
|
||||
#include "nowide/fstream.hpp"
|
||||
#include "variant_visitor.hpp"
|
||||
#include "widgets/lane_order.hpp"
|
||||
#include "utf8_strings.hpp"
|
||||
|
||||
void config::Marker::load_from_v1_0_0_table(const toml::table &tbl) {
|
||||
const auto marker_node = tbl["marker"];
|
||||
@ -100,7 +101,7 @@ config::Config::Config(const std::filesystem::path& settings) :
|
||||
}
|
||||
|
||||
toml::table tbl;
|
||||
nowide::ifstream config_stream{settings};
|
||||
nowide::ifstream config_stream{to_utf8_encoded_string(settings)};
|
||||
try {
|
||||
tbl = toml::parse(config_stream);
|
||||
} catch (const toml::parse_error& err) {
|
||||
@ -135,7 +136,7 @@ toml::table config::Config::dump_as_v1_0_0() {
|
||||
config::Config::~Config() {
|
||||
std::filesystem::create_directories(config_path.parent_path());
|
||||
const auto tbl = dump_as_v1_0_0();
|
||||
nowide::ofstream config_file_stream{config_path};
|
||||
nowide::ofstream config_file_stream{to_utf8_encoded_string(config_path)};
|
||||
const auto flags = (
|
||||
toml::toml_formatter::default_flags
|
||||
& ~toml::format_flags::allow_literal_strings
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "src/better_timing.hpp"
|
||||
#include "src/custom_sfml_audio/synced_sound_streams.hpp"
|
||||
#include "variant_visitor.hpp"
|
||||
#include "utf8_strings.hpp"
|
||||
|
||||
EditorState::EditorState(const std::filesystem::path& assets_, config::Config& config_) :
|
||||
config(config_),
|
||||
@ -1554,7 +1555,7 @@ TimingOrigin EditorState::timing_origin() {
|
||||
|
||||
void EditorState::save(const std::filesystem::path& path) {
|
||||
const auto memon = song.dump_to_memon_1_0_0();
|
||||
nowide::ofstream file{path.string()};
|
||||
nowide::ofstream file{to_utf8_encoded_string(path.string())};
|
||||
if (not file) {
|
||||
throw std::runtime_error(
|
||||
fmt::format("Cannot write to file {}", path.string())
|
||||
@ -1622,8 +1623,7 @@ void feis::open_from_file(
|
||||
config::Config& config
|
||||
) {
|
||||
try {
|
||||
// force utf-8 song path on windows
|
||||
nowide::ifstream f{song_path.string()};
|
||||
nowide::ifstream f{to_utf8_encoded_string(song_path)};
|
||||
if (not f) {
|
||||
tinyfd_messageBox(
|
||||
"Error",
|
||||
|
@ -18,7 +18,7 @@ const std::string recent_files_file = "recent files.txt";
|
||||
void Toolbox::pushNewRecentFile(std::filesystem::path file, std::filesystem::path settings) {
|
||||
std::filesystem::create_directory(settings);
|
||||
auto recent_files_path = settings / recent_files_file;
|
||||
nowide::ifstream readFile(recent_files_path);
|
||||
nowide::ifstream readFile(to_utf8_encoded_string(recent_files_path));
|
||||
std::list<std::string> recent;
|
||||
std::set<std::string> recent_set;
|
||||
for (std::string line; getline(readFile, line);) {
|
||||
@ -38,7 +38,7 @@ void Toolbox::pushNewRecentFile(std::filesystem::path file, std::filesystem::pat
|
||||
recent.push_front(std::filesystem::canonical(file).string());
|
||||
|
||||
nowide::ofstream writeFile(
|
||||
recent_files_path,
|
||||
to_utf8_encoded_string(recent_files_path),
|
||||
std::ofstream::out | std::ofstream::trunc
|
||||
);
|
||||
for (const auto& line : recent) {
|
||||
@ -48,7 +48,7 @@ void Toolbox::pushNewRecentFile(std::filesystem::path file, std::filesystem::pat
|
||||
}
|
||||
|
||||
std::vector<std::string> Toolbox::getRecentFiles(std::filesystem::path settings) {
|
||||
nowide::ifstream readFile{settings / recent_files_file};
|
||||
nowide::ifstream readFile{to_utf8_encoded_string(settings / recent_files_file)};
|
||||
std::vector<std::string> recent;
|
||||
for (std::string line; getline(readFile, line);) {
|
||||
recent.push_back(line);
|
||||
|
Loading…
x
Reference in New Issue
Block a user