| 1481 | // Default file functions |
| 1482 | #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS |
| 1483 | ImFileHandle ImFileOpen(const char* filename, const char* mode) |
| 1484 | { |
| 1485 | #if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__) |
| 1486 | // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. |
| 1487 | const int filename_wsize = ImTextCountCharsFromUtf8(filename, NULL) + 1; |
| 1488 | const int mode_wsize = ImTextCountCharsFromUtf8(mode, NULL) + 1; |
| 1489 | ImVector<ImWchar> buf; |
| 1490 | buf.resize(filename_wsize + mode_wsize); |
| 1491 | ImTextStrFromUtf8(&buf[0], filename_wsize, filename, NULL); |
| 1492 | ImTextStrFromUtf8(&buf[filename_wsize], mode_wsize, mode, NULL); |
| 1493 | return _wfopen((wchar_t*)&buf[0], (wchar_t*)&buf[filename_wsize]); |
| 1494 | #else |
| 1495 | return fopen(filename, mode); |
| 1496 | #endif |
| 1497 | } |
| 1498 | |
| 1499 | // 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. |
| 1500 | bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; } |
no test coverage detected