Commit 70849ee82 for llama.cpp
commit 70849ee82c24b882a483b404d11855a7d7fb1b0c
Author: Adrien Gallouët <angt@huggingface.co>
Date: Fri Oct 2 11:43:45 2026 +0200
common : remove fs_open_ifstream() by using u8path() (#29841)
Signed-off-by: Adrien Gallouët <angt@huggingface.co>
diff --git a/common/common.cpp b/common/common.cpp
index 7ebfa2610..9c07dd84b 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -1071,18 +1071,6 @@ std::vector<common_file_info> fs_list(const std::string & path, bool include_dir
return files;
}
-std::ifstream fs_open_ifstream(const std::string & fname, std::ios_base::openmode mode) {
-#ifdef _WIN32
- int wlen = MultiByteToWideChar(CP_UTF8, 0, fname.c_str(), -1, NULL, 0);
- if (!wlen) { return std::ifstream(); }
- std::vector<wchar_t> wfname(wlen);
- (void)MultiByteToWideChar(CP_UTF8, 0, fname.c_str(), -1, wfname.data(), wlen);
- return std::ifstream(wfname.data(), mode);
-#else
- return std::ifstream(fname, mode);
-#endif
-}
-
//
// TTY utils
//
diff --git a/common/common.h b/common/common.h
index fd90c3b95..49322c81b 100644
--- a/common/common.h
+++ b/common/common.h
@@ -935,9 +935,6 @@ struct common_file_info {
};
std::vector<common_file_info> fs_list(const std::string & path, bool include_directories);
-// fs open, also handle UTF8 on Windows
-std::ifstream fs_open_ifstream(const std::string & fname, std::ios_base::openmode mode);
-
void fs_write_atomic(const std::filesystem::path & path, const std::string & data);
//
diff --git a/tools/server/server-mcp.cpp b/tools/server/server-mcp.cpp
index 88b2c9239..65e39179d 100644
--- a/tools/server/server-mcp.cpp
+++ b/tools/server/server-mcp.cpp
@@ -689,7 +689,7 @@ void server_mcp::start(const common_params & params) {
}
};
if (!params.mcp_servers_config.empty()) {
- std::ifstream f = fs_open_ifstream(params.mcp_servers_config, std::ios::in);
+ std::ifstream f(std::filesystem::u8path(params.mcp_servers_config), std::ios::in);
if (!f) {
throw std::runtime_error("failed to open MCP config file: " + params.mcp_servers_config);
}