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 1bbba6f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fastdeploy/utils/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <sstream>
#include <fstream>
#include <filesystem>
#include <string_view>

#ifdef _WIN32
Expand Down Expand Up @@ -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)
{
Expand All @@ -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) {
Expand Down

0 comments on commit 1bbba6f

Please sign in to comment.