diff --git a/fastdeploy/utils/utils.cc b/fastdeploy/utils/utils.cc index 080aa2e58c..3dbef1212d 100644 --- a/fastdeploy/utils/utils.cc +++ b/fastdeploy/utils/utils.cc @@ -16,7 +16,6 @@ #include #include -#include #include #ifdef _WIN32 @@ -55,7 +54,12 @@ FDLogger& FDLogger::operator<<(std::ostream& (*os)(std::ostream&)) { return *this; } -using os_string = std::filesystem::path::string_type; +// using os_string = std::filesystem::path::string_type; +#ifdef _WIN32 +using os_string = std::wstring; +#else +using os_string = std::string; +#endif os_string to_osstring(std::string_view utf8_str) { @@ -74,12 +78,13 @@ bool ReadBinaryFromFile(const std::string& path, std::string* contents) if (!contents) { return false; } + auto& result = *contents; + result.clear(); + std::ifstream file(to_osstring(path), std::ios::binary | std::ios::ate); if (!file.is_open()) { return false; } - auto& result = *contents; - result.clear(); auto fileSize = file.tellg(); if (fileSize != -1) {