| 2014 | #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS |
| 2015 | |
| 2016 | ImFileHandle ImFileOpen(const char* filename, const char* mode) |
| 2017 | { |
| 2018 | #if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__) |
| 2019 | // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. |
| 2020 | // Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32! |
| 2021 | const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0); |
| 2022 | const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0); |
| 2023 | ImVector<wchar_t> buf; |
| 2024 | buf.resize(filename_wsize + mode_wsize); |
| 2025 | ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (wchar_t*)&buf[0], filename_wsize); |
| 2026 | ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, (wchar_t*)&buf[filename_wsize], mode_wsize); |
| 2027 | return ::_wfopen((const wchar_t*)&buf[0], (const wchar_t*)&buf[filename_wsize]); |
| 2028 | #else |
| 2029 | return fopen(filename, mode); |
| 2030 | #endif |
| 2031 | } |
| 2032 | |
| 2033 | // We should in theory be using fseeko()/ftello() with off_t and _fseeki64()/_ftelli64() with __int64, waiting for the PR that does that in a very portable pre-C++11 zero-warnings way. |
| 2034 | bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; } |
no outgoing calls
no test coverage detected