MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / ImFileOpen

Function ImFileOpen

ImGUI GLFW Tutorial/imgui/imgui.cpp:1543–1558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1541#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
1542
1543ImFileHandle ImFileOpen(const char* filename, const char* mode)
1544{
1545#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__)
1546 // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames.
1547 // Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32!
1548 const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
1549 const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0);
1550 ImVector<ImWchar> buf;
1551 buf.resize(filename_wsize + mode_wsize);
1552 ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (wchar_t*)&buf[0], filename_wsize);
1553 ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, (wchar_t*)&buf[filename_wsize], mode_wsize);
1554 return ::_wfopen((const wchar_t*)&buf[0], (const wchar_t*)&buf[filename_wsize]);
1555#else
1556 return fopen(filename, mode);
1557#endif
1558}
1559
1560// 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.
1561bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; }

Callers 3

ImFileLoadToMemoryFunction · 0.70
LogToFileMethod · 0.70
SaveIniSettingsToDiskMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected