Skip to content

Commit

Permalink
utils: Use _wfopen and _wreopen on Windows
Browse files Browse the repository at this point in the history
The fopen function does not support unicode filename on Windows, so use Windows specific function do deal with it
  • Loading branch information
ken2812221 authored and furszy committed Aug 1, 2021
1 parent 3993641 commit dd94241
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ namespace fsbridge {

FILE *fopen(const fs::path& p, const char *mode)
{
#ifndef WIN32
return ::fopen(p.string().c_str(), mode);
#else
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t> utf8_cvt;
return ::_wfopen(p.wstring().c_str(), utf8_cvt.from_bytes(mode).c_str());
#endif
}


Expand Down

0 comments on commit dd94241

Please sign in to comment.