ODB++: Handle existing output directory gracefully

This commit is contained in:
Jon Evans
2024-11-20 18:14:18 -05:00
parent 66b850a4d2
commit 6a83d7bc76
4 changed files with 27 additions and 6 deletions
+21
View File
@@ -1445,6 +1445,27 @@ void PCB_EDIT_FRAME::GenODBPPFiles( wxCommandEvent& event )
wxFileName tempFile( pcbFileName.GetFullPath(), "" );
tempFile.AppendDir( "odb" );
wxDir testDir( tempFile.GetFullPath() );
if( testDir.IsOpened() && ( testDir.HasFiles() || testDir.HasSubDirs() ) )
{
wxString msg = wxString::Format( _( "Output directory '%s' already exists and is not empty. "
"Do you want to overwrite it?" ),
tempFile.GetFullPath() );
KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
errorDlg.SetOKLabel( _( "Overwrite" ) );
if( errorDlg.ShowModal() != wxID_OK )
return;
if( !tempFile.Rmdir( wxPATH_RMDIR_RECURSIVE ) )
{
msg.Printf( _( "Cannot remove existing output directory '%s'." ),
pcbFileName.GetFullPath() );
return;
}
}
wxString upperTxt;
wxString lowerTxt;