@@ -108,6 +108,12 @@ static const char * in_openmpt_string = "in_openmpt " OPENMPT_API_VERSION_STRING
108108
109109#define SHORT_TITLE " in_openmpt"
110110
111+ #if defined(__GNUC__) && !defined(__clang__)
112+ #if (__GNUC__ < 9)
113+ #define MPT_IN_OPENMPT_FSTREAM_NO_WCHAR
114+ #endif
115+ #endif
116+
111117static void apply_options ();
112118
113119static std::string StringEncode ( const std::wstring &src, UINT codepage )
@@ -309,7 +315,11 @@ static int play( const in_char * fn ) {
309315 return -1 ;
310316 }
311317 try {
318+ #if defined(UNICODE_INPUT_PLUGIN) && defined(MPT_IN_OPENMPT_FSTREAM_NO_WCHAR)
319+ std::ifstream s ( StringEncode ( StringFromWinamp ( fn ), CP_ACP ).c_str (), std::ios::binary );
320+ #else
312321 std::ifstream s ( fn, std::ios::binary );
322+ #endif
313323 std::map< std::string, std::string > ctls;
314324 ctls[" seek.sync_samples" ] = " 1" ;
315325 self->mod = new openmpt::module ( s, std::clog, ctls );
@@ -391,7 +401,11 @@ static void setpan( int pan ) {
391401static int infobox ( const in_char * fn, HWND hWndParent ) {
392402 if ( fn && fn[0 ] != ' \0 ' && self->cached_filename != std::basic_string<TCHAR>(fn) ) {
393403 try {
404+ #if defined(UNICODE_INPUT_PLUGIN) && defined(MPT_IN_OPENMPT_FSTREAM_NO_WCHAR)
405+ std::ifstream s ( StringEncode ( StringFromWinamp ( fn ), CP_ACP ).c_str (), std::ios::binary );
406+ #else
394407 std::ifstream s ( fn, std::ios::binary );
408+ #endif
395409 openmpt::module mod ( s );
396410#if 1
397411 libopenmpt::plugin::gui_show_file_info ( hWndParent, TEXT (SHORT_TITLE), StringReplace ( generate_infotext ( fn, mod ), TEXT (" \n " ), TEXT (" \r\n " ) ) );
@@ -425,7 +439,11 @@ static void getfileinfo( const in_char * filename, in_char * title, int * length
425439 }
426440 } else {
427441 try {
442+ #if defined(UNICODE_INPUT_PLUGIN) && defined(MPT_IN_OPENMPT_FSTREAM_NO_WCHAR)
443+ std::ifstream s ( StringEncode ( StringFromWinamp ( filename ), CP_ACP ).c_str (), std::ios::binary );
444+ #else
428445 std::ifstream s ( filename, std::ios::binary );
446+ #endif
429447 openmpt::module mod ( s );
430448 if ( length_in_ms ) {
431449 *length_in_ms = static_cast <int >( mod.get_duration_seconds () * 1000.0 );
0 commit comments