Skip to content

Commit

Permalink
fix: build error on old C++ std
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Nov 19, 2024
1 parent f5ccf62 commit e5570f3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions fastdeploy/utils/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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)
{
Expand All @@ -74,12 +79,14 @@ bool ReadBinaryFromFile(const std::string& path, std::string* contents)
if (!contents) {
return false;
}
std::ifstream file(to_osstring(path), std::ios::binary | std::ios::ate);
auto& result = *contents;
result.clear();

std::filesystem::path stdpath(to_osstring(path));
std::ifstream file(stdpath, std::ios::binary | std::ios::ate);
if (!file.is_open()) {
return false;
}
auto& result = *contents;
result.clear();

auto fileSize = file.tellg();
if (fileSize != -1) {
Expand Down

0 comments on commit e5570f3

Please sign in to comment.