Let wx auto-close streams in compressed IPC-2581 export.

Removing the temp file was not possible if it's still open.
This commit is contained in:
Alex Shvartzkop 2025-02-16 13:46:10 +03:00 committed by dsa-t
parent 8f7b692720
commit 0594a43cfa
2 changed files with 14 additions and 15 deletions

View File

@ -1387,15 +1387,14 @@ void PCB_EDIT_FRAME::GenIPC2581File( wxCommandEvent& event )
wxFileName zipfn = tempFile;
zipfn.SetExt( "zip" );
wxFFileOutputStream fnout( zipfn.GetFullPath() );
wxZipOutputStream zip( fnout );
wxFFileInputStream fnin( tempFile );
{
wxFFileOutputStream fnout( zipfn.GetFullPath() );
wxZipOutputStream zip( fnout );
wxFFileInputStream fnin( tempFile );
zip.PutNextEntry( tempfn.GetFullName() );
fnin.Read( zip );
zip.Close();
fnout.Close();
fnin.GetFile()->Close();
zip.PutNextEntry( tempfn.GetFullName() );
fnin.Read( zip );
}
wxRemoveFile( tempFile );
tempFile = zipfn.GetFullPath();

View File

@ -2025,14 +2025,14 @@ int PCBNEW_JOBS_HANDLER::JobExportIpc2581( JOB* aJob )
wxFileName zipfn = tempFile;
zipfn.SetExt( "zip" );
wxFFileOutputStream fnout( zipfn.GetFullPath() );
wxZipOutputStream zip( fnout );
wxFFileInputStream fnin( tempFile );
{
wxFFileOutputStream fnout( zipfn.GetFullPath() );
wxZipOutputStream zip( fnout );
wxFFileInputStream fnin( tempFile );
zip.PutNextEntry( tempfn.GetFullName() );
fnin.Read( zip );
zip.Close();
fnout.Close();
zip.PutNextEntry( tempfn.GetFullName() );
fnin.Read( zip );
}
wxRemoveFile( tempFile );
tempFile = zipfn.GetFullPath();