diff --git a/examples/cli/image_metadata.cpp b/examples/cli/image_metadata.cpp index 8dd339c88..ba0d6da23 100644 --- a/examples/cli/image_metadata.cpp +++ b/examples/cli/image_metadata.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -276,7 +277,7 @@ namespace { } bool read_file(const std::string& path, std::vector& data, std::string& error) { - std::ifstream fin(path, std::ios::binary); + std::ifstream fin(std::filesystem::u8path(path), std::ios::binary); if (!fin) { error = "failed to open file: " + path; return false; diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp index e8174d27c..ca8ce4e79 100644 --- a/examples/cli/main.cpp +++ b/examples/cli/main.cpp @@ -188,7 +188,7 @@ struct SDCliParams { if (++index >= argc) { return -1; } - imatrix_in.push_back(argv[index]); + imatrix_in.push_back(argv_to_utf8(index, argv)); return 1; }; @@ -323,13 +323,14 @@ void sd_log_cb(enum sd_log_level_t level, const char* log, void* data) { bool load_images_from_dir(const std::string dir, std::vector& images, int max_image_num = 0) { - if (!fs::exists(dir) || !fs::is_directory(dir)) { + const fs::path dir_path = fs::u8path(dir); + if (!fs::exists(dir_path) || !fs::is_directory(dir_path)) { LOG_ERROR("'%s' is not a valid directory\n", dir.c_str()); return false; } std::vector entries; - for (const auto& entry : fs::directory_iterator(dir)) { + for (const auto& entry : fs::directory_iterator(dir_path)) { if (entry.is_regular_file()) { entries.push_back(entry); } @@ -337,12 +338,12 @@ bool load_images_from_dir(const std::string dir, std::sort(entries.begin(), entries.end(), [](const fs::directory_entry& a, const fs::directory_entry& b) { - return a.path().filename().string() < b.path().filename().string(); + return a.path().filename().u8string() < b.path().filename().u8string(); }); for (const auto& entry : entries) { - std::string path = entry.path().string(); - std::string ext = entry.path().extension().string(); + std::string path = entry.path().u8string(); + std::string ext = entry.path().extension().u8string(); std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); if (ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp" || ext == ".webp") { @@ -397,19 +398,19 @@ void step_callback(int step, int frame_count, sd_image_t* image, bool is_noisy, // is_noisy is set to true if the preview corresponds to noisy latents, false if it's denoised latents // unused in this app, it will either be always noisy or always denoised here if (frame_count == 1) { - fs::path path = cli_params->preview_path; - if (encoded_image_format_from_path(path.string()) == EncodedImageFormat::UNKNOWN) + fs::path path = fs::u8path(cli_params->preview_path); + if (encoded_image_format_from_path(path.u8string()) == EncodedImageFormat::UNKNOWN) path += ".png"; - if (std::regex_search(path.string(), format_specifier_regex)) - path = fs::path(format_frame_idx(path.string(), continuous_preview_counter++)); - if (!write_image_to_file(path.string(), + if (std::regex_search(path.u8string(), format_specifier_regex)) + path = fs::u8path(format_frame_idx(path.u8string(), continuous_preview_counter++)); + if (!write_image_to_file(path.u8string(), image->data, image->width, image->height, image->channel, "", cli_params->compression_quality)) { - LOG_ERROR("save preview image to '%s' failed", path.string().c_str()); + LOG_ERROR("save preview image to '%s' failed", path.u8string().c_str()); } } else { int fps = cli_params->preview_method == PREVIEW_PROJ ? cli_params->preview_fps / 4 : cli_params->preview_fps; @@ -420,12 +421,12 @@ void step_callback(int step, int frame_count, sd_image_t* image, bool is_noisy, } static fs::path get_video_audio_sidecar_path(const SDCliParams& cli_params) { - fs::path out_path = cli_params.output_path; + fs::path out_path = fs::u8path(cli_params.output_path); fs::path base_path = out_path; fs::path ext = out_path.has_extension() ? out_path.extension() : fs::path{}; - std::string ext_lower = ext.string(); + std::string ext_lower = ext.u8string(); std::transform(ext_lower.begin(), ext_lower.end(), ext_lower.begin(), ::tolower); - const EncodedImageFormat output_format = encoded_image_format_from_path(out_path.string()); + const EncodedImageFormat output_format = encoded_image_format_from_path(out_path.u8string()); if (!ext.empty()) { if (output_format == EncodedImageFormat::JPEG || output_format == EncodedImageFormat::PNG || @@ -450,14 +451,14 @@ bool save_results(const SDCliParams& cli_params, } namespace fs = std::filesystem; - fs::path out_path = cli_params.output_path; + fs::path out_path = fs::u8path(cli_params.output_path); if (!out_path.parent_path().empty()) { std::error_code ec; fs::create_directories(out_path.parent_path(), ec); if (ec) { LOG_ERROR("failed to create directory '%s': %s", - out_path.parent_path().string().c_str(), ec.message().c_str()); + out_path.parent_path().u8string().c_str(), ec.message().c_str()); return false; } } @@ -465,9 +466,9 @@ bool save_results(const SDCliParams& cli_params, fs::path base_path = out_path; fs::path ext = out_path.has_extension() ? out_path.extension() : fs::path{}; - std::string ext_lower = ext.string(); + std::string ext_lower = ext.u8string(); std::transform(ext_lower.begin(), ext_lower.end(), ext_lower.begin(), ::tolower); - const EncodedImageFormat output_format = encoded_image_format_from_path(out_path.string()); + const EncodedImageFormat output_format = encoded_image_format_from_path(out_path.u8string()); if (!ext.empty()) { if (output_format == EncodedImageFormat::JPEG || output_format == EncodedImageFormat::PNG || @@ -493,8 +494,8 @@ bool save_results(const SDCliParams& cli_params, std::string params = gen_params.embed_image_metadata ? get_image_params(ctx_params, gen_params, metadata_seed, cli_params.mode) : ""; - const bool ok = write_image_to_file(path.string(), img.data, img.width, img.height, img.channel, params, cli_params.compression_quality); - LOG_INFO("save result image %d to '%s' (%s)", idx, path.string().c_str(), ok ? "success" : "failure"); + const bool ok = write_image_to_file(path.u8string(), img.data, img.width, img.height, img.channel, params, cli_params.compression_quality); + LOG_INFO("save result image %d to '%s' (%s)", idx, path.u8string().c_str(), ok ? "success" : "failure"); return ok; }; @@ -502,14 +503,14 @@ bool save_results(const SDCliParams& cli_params, if (generated_audio == nullptr) { return; } - if (write_wav_to_file(wav_path.string(), + if (write_wav_to_file(wav_path.u8string(), generated_audio->data, generated_audio->sample_count, generated_audio->channels, generated_audio->sample_rate)) { - LOG_INFO("save result audio to '%s'", wav_path.string().c_str()); + LOG_INFO("save result audio to '%s'", wav_path.u8string().c_str()); } else { - LOG_WARN("failed to save result audio to '%s'", wav_path.string().c_str()); + LOG_WARN("failed to save result audio to '%s'", wav_path.u8string().c_str()); } }; @@ -522,7 +523,7 @@ bool save_results(const SDCliParams& cli_params, pattern += ext; for (int i = 0; i < num_results; ++i) { - fs::path img_path = format_frame_idx(pattern.string(), output_begin_idx + i); + fs::path img_path = fs::u8path(format_frame_idx(pattern.u8string(), output_begin_idx + i)); if (write_image(img_path, i)) { sucessful_reults++; } @@ -540,11 +541,11 @@ bool save_results(const SDCliParams& cli_params, fs::path video_path = base_path; video_path += ext; - std::string final_ext_lower = ext.string(); + std::string final_ext_lower = ext.u8string(); std::transform(final_ext_lower.begin(), final_ext_lower.end(), final_ext_lower.begin(), ::tolower); const bool mux_audio = generated_audio != nullptr && (final_ext_lower == ".avi" || final_ext_lower == ".webm"); - if (create_video_from_sd_images(video_path.string().c_str(), results, num_results, gen_params.fps, cli_params.compression_quality, mux_audio ? generated_audio : nullptr, params) == 0) { - LOG_INFO("save result video to '%s'", video_path.string().c_str()); + if (create_video_from_sd_images(video_path.u8string().c_str(), results, num_results, gen_params.fps, cli_params.compression_quality, mux_audio ? generated_audio : nullptr, params) == 0) { + LOG_INFO("save result video to '%s'", video_path.u8string().c_str()); if (generated_audio != nullptr && !mux_audio) { fs::path wav_path = video_path; wav_path.replace_extension(".wav"); @@ -552,7 +553,7 @@ bool save_results(const SDCliParams& cli_params, } return true; } else { - LOG_ERROR("Failed to save result video to '%s'", video_path.string().c_str()); + LOG_ERROR("Failed to save result video to '%s'", video_path.u8string().c_str()); return false; } } @@ -701,7 +702,7 @@ int main(int argc, const char* argv[]) { LOG_DEBUG("%s", gen_params.to_string().c_str()); if (!cli_params.imatrix_out.empty()) { - if (fs::exists(cli_params.imatrix_out) && + if (fs::exists(fs::u8path(cli_params.imatrix_out)) && std::find(cli_params.imatrix_in.begin(), cli_params.imatrix_in.end(), cli_params.imatrix_out) == cli_params.imatrix_in.end()) { LOG_WARN("imatrix file '%s' already exists and will be overwritten", cli_params.imatrix_out.c_str()); } diff --git a/examples/common/common.cpp b/examples/common/common.cpp index 11b531f46..5fd016bce 100644 --- a/examples/common/common.cpp +++ b/examples/common/common.cpp @@ -75,7 +75,7 @@ static std::string utf16_to_utf8(const std::wstring& wstr) { return utf8; } -static std::string argv_to_utf8(int index, const char** argv) { +std::string argv_to_utf8(int index, const char** argv) { (void)argv; int argc; wchar_t** argv_w = CommandLineToArgvW(GetCommandLineW(), &argc); @@ -91,7 +91,7 @@ static std::string argv_to_utf8(int index, const char** argv) { } #else // Linux / macOS -static std::string argv_to_utf8(int index, const char** argv) { +std::string argv_to_utf8(int index, const char** argv) { return std::string(argv[index]); } @@ -839,16 +839,17 @@ ArgOptions SDContextParams::get_options() { void SDContextParams::build_embedding_map() { static const std::vector valid_ext = {".gguf", ".safetensors", ".pt", ".ckpt"}; - if (!fs::exists(embedding_dir) || !fs::is_directory(embedding_dir)) { + const fs::path embedding_dir_path = fs::u8path(embedding_dir); + if (!fs::exists(embedding_dir_path) || !fs::is_directory(embedding_dir_path)) { return; } - for (auto& p : fs::directory_iterator(embedding_dir)) { + for (auto& p : fs::directory_iterator(embedding_dir_path)) { if (!p.is_regular_file()) continue; auto path = p.path(); - std::string ext = path.extension().string(); + std::string ext = path.extension().u8string(); bool valid = false; for (auto& e : valid_ext) { @@ -860,8 +861,8 @@ void SDContextParams::build_embedding_map() { if (!valid) continue; - std::string key = path.stem().string(); - std::string value = path.string(); + std::string key = path.stem().u8string(); + std::string value = path.u8string(); embedding_map[key] = value; } @@ -1572,7 +1573,7 @@ ArgOptions SDGenerationParams::get_options() { if (++index >= argc) { return -1; } - ref_image_paths.push_back(argv[index]); + ref_image_paths.push_back(argv_to_utf8(index, argv)); return 1; }; @@ -1580,7 +1581,7 @@ ArgOptions SDGenerationParams::get_options() { if (++index >= argc) { return -1; } - ref_video_paths.push_back(argv[index]); + ref_video_paths.push_back(argv_to_utf8(index, argv)); return 1; }; @@ -1588,7 +1589,7 @@ ArgOptions SDGenerationParams::get_options() { if (++index >= argc) { return -1; } - ref_video_audio_paths.push_back(argv[index]); + ref_video_audio_paths.push_back(argv_to_utf8(index, argv)); return 1; }; @@ -1596,7 +1597,7 @@ ArgOptions SDGenerationParams::get_options() { if (++index >= argc) { return -1; } - ref_audio_paths.push_back(argv[index]); + ref_audio_paths.push_back(argv_to_utf8(index, argv)); return 1; }; @@ -1604,7 +1605,7 @@ ArgOptions SDGenerationParams::get_options() { if (++index >= argc) { return -1; } - ref_audio_paths.push_back(argv[index]); + ref_audio_paths.push_back(argv_to_utf8(index, argv)); return 1; }; @@ -1703,15 +1704,15 @@ ArgOptions SDGenerationParams::get_options() { if (++index >= argc) { return -1; } - const char* arg = argv[index]; - std::ifstream f(arg, std::ios::binary); + const std::string arg = argv_to_utf8(index, argv); + std::ifstream f(fs::u8path(arg), std::ios::binary); try { prompt = std::string(std::istreambuf_iterator{f}, {}); } catch (const std::ios_base::failure&) { f.setstate(std::ios_base::failbit); } if (f.fail()) { - LOG_ERROR("error: failed to read prompt file '%s'\n", arg); + LOG_ERROR("error: failed to read prompt file '%s'\n", arg.c_str()); return -1; } return 1; @@ -1721,15 +1722,15 @@ ArgOptions SDGenerationParams::get_options() { if (++index >= argc) { return -1; } - const char* arg = argv[index]; - std::ifstream f(arg, std::ios::binary); + const std::string arg = argv_to_utf8(index, argv); + std::ifstream f(fs::u8path(arg), std::ios::binary); try { negative_prompt = std::string(std::istreambuf_iterator{f}, {}); } catch (const std::ios_base::failure&) { f.setstate(std::ios_base::failbit); } if (f.fail()) { - LOG_ERROR("error: failed to read negative prompt file '%s'\n", arg); + LOG_ERROR("error: failed to read negative prompt file '%s'\n", arg.c_str()); return -1; } return 1; @@ -2050,22 +2051,22 @@ static bool resolve_model_file_from_dir(const std::string& model_name, if (model_name.empty() || model_name.find('/') != std::string::npos || model_name.find('\\') != std::string::npos || - fs::path(model_name).has_root_path() || + fs::u8path(model_name).has_root_path() || ends_with_valid_ext()) { LOG_ERROR("%s must be a model name without path or extension: %s", label, model_name.c_str()); return false; } - fs::path model_dir_path = model_dir; + fs::path model_dir_path = fs::u8path(model_dir); for (const auto& ext : valid_ext) { - fs::path try_path = model_dir_path / (model_name + ext); + fs::path try_path = model_dir_path / fs::u8path(model_name + ext); if (fs::exists(try_path) && fs::is_regular_file(try_path)) { - resolved_path = try_path.lexically_normal().string(); + resolved_path = try_path.lexically_normal().u8string(); return true; } } - LOG_ERROR("can not find %s %s in %s", label, model_name.c_str(), model_dir_path.lexically_normal().string().c_str()); + LOG_ERROR("can not find %s %s in %s", label, model_name.c_str(), model_dir_path.lexically_normal().u8string().c_str()); return false; } @@ -2359,10 +2360,18 @@ bool SDGenerationParams::extract_and_remove_lora(const std::string& lora_model_d } fs::path final_path; - if (is_absolute_path(raw_path)) { - final_path = raw_path; - } else { - final_path = fs::path(lora_model_dir) / raw_path; + try { + if (is_absolute_path(raw_path)) { + final_path = fs::u8path(raw_path); + } else { + final_path = fs::u8path(lora_model_dir) / fs::u8path(raw_path); + } + } catch (const std::exception&) { // not UTF-8, e.g. a prompt file in another encoding + LOG_WARN("invalid lora path %s", raw_path.c_str()); + tmp = m.suffix().str(); + prompt = std::regex_replace(prompt, re, "", std::regex_constants::format_first_only); + missing = true; + continue; } if (!fs::exists(final_path)) { bool found = false; @@ -2376,7 +2385,7 @@ bool SDGenerationParams::extract_and_remove_lora(const std::string& lora_model_d } } if (!found) { - LOG_WARN("can not found lora %s", final_path.lexically_normal().string().c_str()); + LOG_WARN("can not found lora %s", final_path.lexically_normal().u8string().c_str()); tmp = m.suffix().str(); prompt = std::regex_replace(prompt, re, "", std::regex_constants::format_first_only); missing = true; @@ -2384,7 +2393,7 @@ bool SDGenerationParams::extract_and_remove_lora(const std::string& lora_model_d } } - const std::string key = final_path.lexically_normal().string(); + const std::string key = final_path.lexically_normal().u8string(); if (is_high_noise) high_noise_lora_map[key] += mul; diff --git a/examples/common/common.h b/examples/common/common.h index 74a057d0b..91e75c685 100644 --- a/examples/common/common.h +++ b/examples/common/common.h @@ -12,6 +12,10 @@ #include "resource_owners.hpp" #include "stable-diffusion.h" +// The command-line argument at `index` as UTF-8 (on Windows, read again from +// the UTF-16 command line: argv itself is in the ANSI code page). +std::string argv_to_utf8(int index, const char** argv); + #define SAFE_STR(s) ((s) ? (s) : "") #define BOOL_STR(b) ((b) ? "true" : "false") diff --git a/examples/common/media_io.cpp b/examples/common/media_io.cpp index ba0e8c5b2..baac6d200 100644 --- a/examples/common/media_io.cpp +++ b/examples/common/media_io.cpp @@ -15,10 +15,12 @@ #define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_STATIC +#define STBI_WINDOWS_UTF8 #include "stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_STATIC +#define STBIW_WINDOWS_UTF8 #include "stb_image_write.h" #define STB_IMAGE_RESIZE_IMPLEMENTATION @@ -147,7 +149,7 @@ class MemoryMkvWriter : public mkvmuxer::IMkvWriter { #endif bool read_binary_file_bytes(const char* path, std::vector& data) { - std::ifstream fin(fs::path(path), std::ios::binary); + std::ifstream fin(fs::u8path(path), std::ios::binary); if (!fin) { return false; } @@ -170,7 +172,7 @@ bool read_binary_file_bytes(const char* path, std::vector& data) { } bool write_binary_file_bytes(const std::string& path, const std::vector& data) { - std::ofstream fout(fs::path(path), std::ios::binary); + std::ofstream fout(fs::u8path(path), std::ios::binary); if (!fout) { return false; } @@ -714,7 +716,7 @@ static std::pair audio_sample_range_for_video_frame(const sd } EncodedImageFormat encoded_image_format_from_path(const std::string& path) { - std::string ext = fs::path(path).extension().string(); + std::string ext = fs::u8path(path).extension().u8string(); std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); if (ext == ".jpg" || ext == ".jpeg" || ext == ".jpe") { @@ -1413,7 +1415,7 @@ bool write_wav_to_file(const std::string& path, return false; } - std::ofstream file(path, std::ios::binary); + std::ofstream file(fs::u8path(path), std::ios::binary); if (!file.is_open()) { return false; } @@ -1475,7 +1477,7 @@ bool load_wav_from_file(const std::string& path, sample_rate = 0; channels = 0; - std::ifstream file(path, std::ios::binary); + std::ifstream file(fs::u8path(path), std::ios::binary); uint8_t riff_header[12]; if (!file.read(reinterpret_cast(riff_header), sizeof(riff_header)) || std::memcmp(riff_header, "RIFF", 4) != 0 || diff --git a/examples/server/routes_index.cpp b/examples/server/routes_index.cpp index 1341ff84a..14ad814b4 100644 --- a/examples/server/routes_index.cpp +++ b/examples/server/routes_index.cpp @@ -1,5 +1,6 @@ #include "routes.h" +#include #include #include @@ -7,7 +8,7 @@ void register_index_endpoints(httplib::Server& svr, const SDSvrParams& svr_param const std::string serve_html_path = svr_params.serve_html_path; svr.Get("/", [serve_html_path, index_html](const httplib::Request&, httplib::Response& res) { if (!serve_html_path.empty()) { - std::ifstream file(serve_html_path); + std::ifstream file(std::filesystem::u8path(serve_html_path)); if (file) { std::string content((std::istreambuf_iterator(file)), std::istreambuf_iterator()); res.set_content(content, "text/html"); diff --git a/examples/server/routes_sdapi.cpp b/examples/server/routes_sdapi.cpp index 22a710b7e..158b2afdc 100644 --- a/examples/server/routes_sdapi.cpp +++ b/examples/server/routes_sdapi.cpp @@ -28,10 +28,10 @@ static std::string extract_and_remove_sd_cpp_extra_args(std::string& text) { static fs::path resolve_display_model_path(const ServerRuntime& runtime) { const auto& ctx = *runtime.ctx_params; if (!ctx.model_path.empty()) { - return fs::path(ctx.model_path); + return fs::u8path(ctx.model_path); } if (!ctx.diffusion_model_path.empty()) { - return fs::path(ctx.diffusion_model_path); + return fs::u8path(ctx.diffusion_model_path); } return {}; } @@ -583,9 +583,9 @@ void register_sdapi_endpoints(httplib::Server& svr, ServerRuntime& rt) { svr.Get("/sdapi/v1/sd-models", [runtime](const httplib::Request&, httplib::Response& res) { fs::path model_path = resolve_display_model_path(*runtime); json entry; - entry["title"] = model_path.stem(); - entry["model_name"] = model_path.stem(); - entry["filename"] = model_path.filename(); + entry["title"] = model_path.stem().u8string(); + entry["model_name"] = model_path.stem().u8string(); + entry["filename"] = model_path.filename().u8string(); entry["hash"] = "8888888888"; entry["sha256"] = "8888888888888888888888888888888888888888888888888888888888888888"; entry["config"] = nullptr; @@ -598,7 +598,7 @@ void register_sdapi_endpoints(httplib::Server& svr, ServerRuntime& rt) { fs::path model_path = resolve_display_model_path(*runtime); json r; r["samples_format"] = "png"; - r["sd_model_checkpoint"] = model_path.stem(); + r["sd_model_checkpoint"] = model_path.stem().u8string(); res.set_content(r.dump(), "application/json"); }); diff --git a/examples/server/routes_sdcpp.cpp b/examples/server/routes_sdcpp.cpp index 3139682f9..a6c8a1e8d 100644 --- a/examples/server/routes_sdcpp.cpp +++ b/examples/server/routes_sdcpp.cpp @@ -90,10 +90,10 @@ static json make_vae_tiling_json(const sd_tiling_params_t& params) { static fs::path resolve_display_model_path(const ServerRuntime& runtime) { const auto& ctx = *runtime.ctx_params; if (!ctx.model_path.empty()) { - return fs::path(ctx.model_path); + return fs::u8path(ctx.model_path); } if (!ctx.diffusion_model_path.empty()) { - return fs::path(ctx.diffusion_model_path); + return fs::u8path(ctx.diffusion_model_path); } return {}; } diff --git a/examples/server/runtime.cpp b/examples/server/runtime.cpp index 1a71cf76f..76d89d397 100644 --- a/examples/server/runtime.cpp +++ b/examples/server/runtime.cpp @@ -22,7 +22,7 @@ static std::string lower_ascii(std::string value) { } static bool is_supported_model_ext(const fs::path& p) { - auto ext = lower_ascii(p.extension().string()); + auto ext = lower_ascii(p.extension().u8string()); return ext == ".gguf" || ext == ".pt" || ext == ".pth" || ext == ".safetensors"; } @@ -226,7 +226,7 @@ bool SDSvrParams::validate() { return false; } - if (!serve_html_path.empty() && !fs::exists(serve_html_path)) { + if (!serve_html_path.empty() && !fs::exists(fs::u8path(serve_html_path))) { LOG_ERROR("error: serve_html_path file does not exist: %s", serve_html_path.c_str()); return false; } @@ -260,7 +260,7 @@ void refresh_lora_cache(ServerRuntime& rt) { return; } - fs::path lora_dir = rt.ctx_params->lora_model_dir; + fs::path lora_dir = fs::u8path(rt.ctx_params->lora_model_dir); std::error_code ec; if (fs::exists(lora_dir, ec) && !ec && fs::is_directory(lora_dir, ec) && !ec) { try { @@ -293,13 +293,13 @@ void refresh_lora_cache(ServerRuntime& rt) { it.increment(ec); } } catch (const std::exception& e) { - LOG_WARN("error while scanning lora directory '%s': %s", lora_dir.string().c_str(), e.what()); + LOG_WARN("error while scanning lora directory '%s': %s", lora_dir.u8string().c_str(), e.what()); return; } } if (ec) { - LOG_WARN("error while scanning lora directory '%s': %s", lora_dir.string().c_str(), ec.message().c_str()); + LOG_WARN("error while scanning lora directory '%s': %s", lora_dir.u8string().c_str(), ec.message().c_str()); return; } @@ -328,7 +328,7 @@ void refresh_upscaler_cache(ServerRuntime& rt) { previous_cache = *rt.upscaler_cache; } - fs::path upscaler_dir = rt.ctx_params->hires_upscalers_dir; + fs::path upscaler_dir = fs::u8path(rt.ctx_params->hires_upscalers_dir); std::error_code ec; if (fs::exists(upscaler_dir, ec) && !ec && fs::is_directory(upscaler_dir, ec) && !ec) { try { @@ -384,13 +384,13 @@ void refresh_upscaler_cache(ServerRuntime& rt) { it.increment(ec); } } catch (const std::exception& e) { - LOG_WARN("error while scanning upscalers directory '%s': %s", upscaler_dir.string().c_str(), e.what()); + LOG_WARN("error while scanning upscalers directory '%s': %s", upscaler_dir.u8string().c_str(), e.what()); return; } } if (ec) { - LOG_WARN("error while scanning upscalers directory '%s': %s", upscaler_dir.string().c_str(), ec.message().c_str()); + LOG_WARN("error while scanning upscalers directory '%s': %s", upscaler_dir.u8string().c_str(), ec.message().c_str()); return; }