Browse Source

Unify embedded file writing

For unknown reasons, one method of writing was not working on Windows.
This is an attempt to write using the common wxFFileOutputStream to see
if that results in better output for Windows clients

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20006
revert-0c36e162
Seth Hillbrand 9 months ago
parent
commit
03af293683
  1. 11
      common/dialogs/panel_embedded_files.cpp

11
common/dialogs/panel_embedded_files.cpp

@ -36,6 +36,7 @@
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/menu.h>
#include <wx/wfstream.h>
/* ---------- GRID_TRICKS for embedded files grid ---------- */
@ -445,9 +446,10 @@ void PANEL_EMBEDDED_FILES::onExportFiles( wxCommandEvent& event )
if( skip_file )
continue;
wxFFile ffile( fileName.GetFullPath(), wxT( "w" ) );
if( !ffile.IsOpened() )
wxFFileOutputStream out( fileName.GetFullPath() );
if( !out.IsOk() )
{
wxString msg = wxString::Format( _( "Failed to open file '%s'." ),
fileName.GetFullName() );
@ -457,12 +459,15 @@ void PANEL_EMBEDDED_FILES::onExportFiles( wxCommandEvent& event )
continue;
}
if( !ffile.Write( file->decompressedData.data(), file->decompressedData.size() ) )
out.Write( file->decompressedData.data(), file->decompressedData.size() );
if( !out.IsOk() || ( out.LastWrite() != file->decompressedData.size() ) )
{
wxString msg = wxString::Format( _( "Failed to write file '%s'." ),
fileName.GetFullName() );
KIDIALOG errorDlg( m_parent, msg, _( "Error" ), wxOK | wxICON_ERROR );
errorDlg.ShowModal();
}
}

Loading…
Cancel
Save