Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion base/file_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <string>
#include <fstream>
#include <filesystem>


namespace ort_extensions {
Expand Down Expand Up @@ -51,7 +52,12 @@ class path {
std::ifstream open(ios_base::openmode mode = ios_base::in) const {
// if Windows, need to convert the string to UTF-16
#ifdef _WIN32
return std::ifstream(w_path_, mode);
// libc++ (the Windows clang toolchain) provides no std::ifstream ctor
// taking a std::wstring -- that overload is an MSVC-STL extension. Route
// the wide path through std::filesystem::path, whose basic_ifstream ctor
// overload is standard C++17 and is honoured by libc++/libstdc++/MSVC STL
// alike, while still preserving the UTF-16 path. (microsoft/onnxruntime-extensions#1071)
return std::ifstream(std::filesystem::path(w_path_), mode);
#else
return std::ifstream(path_, mode);
#endif // _WIN32
Expand Down