@ -1293,6 +1293,22 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float&
}
}
FILE * ImFileOpen ( const char * filename , const char * mode )
{
# ifdef _MSC_VER
// We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. Converting both strings from UTF-8 to wchar format (using a single allocation, because we can)
const int filename_wsize = ImTextCountCharsFromUtf8 ( filename , NULL ) + 1 ;
const int mode_wsize = ImTextCountCharsFromUtf8 ( mode , NULL ) + 1 ;
ImVector < ImWchar > buf ;
buf . resize ( filename_wsize + mode_wsize ) ;
ImTextStrFromUtf8 ( & buf [ 0 ] , filename_wsize , filename , NULL ) ;
ImTextStrFromUtf8 ( & buf [ filename_wsize ] , mode_wsize , mode , NULL ) ;
return _wfopen ( ( wchar_t * ) & buf [ 0 ] , ( wchar_t * ) & buf [ filename_wsize ] ) ;
# else
return fopen ( filename , mode ) ;
# endif
}
// Load file content into memory
// Memory allocated with ImGui::MemAlloc(), must be freed by user using ImGui::MemFree()
void * ImLoadFileToMemory ( const char * filename , const char * file_open_mode , int * out_file_size , int padding_bytes )
@ -1302,7 +1318,7 @@ void* ImLoadFileToMemory(const char* filename, const char* file_open_mode, int*
* out_file_size = 0 ;
FILE * f ;
if ( ( f = fo pen( filename , file_open_mode ) ) = = NULL )
if ( ( f = ImFileO pen( filename , file_open_mode ) ) = = NULL )
return NULL ;
long file_size_signed ;
@ -2501,7 +2517,7 @@ static void SaveSettings()
// Write .ini file
// If a window wasn't opened in this session we preserve its settings
FILE * f = fo pen( filename , " wt " ) ;
FILE * f = ImFileO pen( filename , " wt " ) ;
if ( ! f )
return ;
for ( int i = 0 ; i ! = g . Settings . Size ; i + + )
@ -5784,7 +5800,7 @@ void ImGui::LogToFile(int max_depth, const char* filename)
return ;
}
g . LogFile = fo pen( filename , " ab " ) ;
g . LogFile = ImFileO pen( filename , " ab " ) ;
if ( ! g . LogFile )
{
IM_ASSERT ( g . LogFile ! = NULL ) ; // Consider this an error