MCPcopy Create free account
hub / github.com/AlexandreRouma/SDRPlusPlus / ImFileOpen

Function ImFileOpen

core/src/imgui/imgui.cpp:1546–1561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

ImFileLoadToMemoryFunction · 0.70
LogToFileMethod · 0.70
SaveIniSettingsToDiskMethod · 0.70

Calls 1

resizeMethod · 0.80

Tested by

no test coverage detected