JSON_SETTINGS: partial fix of non ascii7 filenames on Windows.

It should work with ASCII8 filenames, but the member
m_filename is probably not always correctly initialized in all cases.
This commit is contained in:
jean-pierre charras 2020-08-01 15:24:57 +02:00
parent 93e3268030
commit 91e00e14a9
1 changed files with 9 additions and 4 deletions

View File

@ -158,8 +158,7 @@ bool JSON_SETTINGS::LoadFromFile( const std::string& aDirectory )
else
{
wxString dir( aDirectory.c_str(), wxConvUTF8 );
wxString name( m_filename.c_str(), wxConvUTF8 );
path.Assign( dir, name, getFileExt() );
path.Assign( dir, m_filename, getFileExt() );
}
if( !path.Exists() )
@ -349,21 +348,27 @@ bool JSON_SETTINGS::SaveToFile( const std::string& aDirectory, bool aForce )
wxLogTrace( traceSettings, "Saving %s", GetFullFilename() );
LOCALE_IO dummy;
bool success = true;
try
{
wxFile file( path.GetFullPath(), wxFile::write );
if( !file.IsOpened() || !file.Write( wxString( dump( 0 ).c_str(), wxConvUTF8 ) ) )
std::stringstream buffer;
buffer << std::setw( 2 ) << *this << std::endl;
if( !file.IsOpened() || !file.Write( buffer.str().c_str(), buffer.str().size() ) )
{
wxLogTrace( traceSettings, "Warning: could not save %s", GetFullFilename() );
success = false;
}
}
catch( ... )
{
success = false;
}
return true;
return success;
}