fixed unicode paths

This commit is contained in:
Concedo 2025-05-11 14:05:54 +08:00
parent 75ec0ba279
commit f841b29c41
4 changed files with 46 additions and 7 deletions

View file

@ -19,6 +19,7 @@
#include <string>
#include <unordered_map>
#include <vector>
#include <filesystem>
#include "ggml-alloc.h"
#include "ggml-backend.h"
@ -218,7 +219,12 @@ __STATIC_INLINE__ void print_ggml_tensor(struct ggml_tensor* tensor, bool shape_
}
__STATIC_INLINE__ ggml_tensor* load_tensor_from_file(ggml_context* ctx, const std::string& file_path) {
std::ifstream file(file_path, std::ios::binary);
#ifdef _WIN32
std::filesystem::path fpath = std::filesystem::u8path(file_path);
#else
std::filesystem::path fpath = std::filesystem::path(file_path);
#endif
std::ifstream file(fpath, std::ios::binary);
if (!file.is_open()) {
LOG_ERROR("failed to open '%s'", file_path.c_str());
return NULL;