diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 96da9c6163..cfe3a9e650 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -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; diff --git a/pcbnew/pcb_io/odbpp/odb_entity.cpp b/pcbnew/pcb_io/odbpp/odb_entity.cpp index 809a260f57..90756d8dbe 100644 --- a/pcbnew/pcb_io/odbpp/odb_entity.cpp +++ b/pcbnew/pcb_io/odbpp/odb_entity.cpp @@ -59,7 +59,7 @@ #include "pcb_io_odbpp.h" -bool ODB_ENTITY_BASE::CreateDirectiryTree( ODB_TREE_WRITER& writer ) +bool ODB_ENTITY_BASE::CreateDirectoryTree( ODB_TREE_WRITER& writer ) { try { @@ -857,7 +857,7 @@ void ODB_STEP_ENTITY::GenerateNetlistsFiles( ODB_TREE_WRITER& writer ) } -bool ODB_STEP_ENTITY::CreateDirectiryTree( ODB_TREE_WRITER& writer ) +bool ODB_STEP_ENTITY::CreateDirectoryTree( ODB_TREE_WRITER& writer ) { try { diff --git a/pcbnew/pcb_io/odbpp/odb_entity.h b/pcbnew/pcb_io/odbpp/odb_entity.h index 293e454100..8acb0d10be 100644 --- a/pcbnew/pcb_io/odbpp/odb_entity.h +++ b/pcbnew/pcb_io/odbpp/odb_entity.h @@ -50,7 +50,7 @@ public: virtual ~ODB_ENTITY_BASE() = default; virtual void GenerateFiles( ODB_TREE_WRITER& writer ) {} - virtual bool CreateDirectiryTree( ODB_TREE_WRITER& writer ); + virtual bool CreateDirectoryTree( ODB_TREE_WRITER& writer ); virtual std::string GetEntityName() = 0; virtual void InitEntityData() {} @@ -151,7 +151,7 @@ public: bool AddProfile(); bool AddStepHeader(); - virtual bool CreateDirectiryTree( ODB_TREE_WRITER& writer ) override; + virtual bool CreateDirectoryTree( ODB_TREE_WRITER& writer ) override; virtual void InitEntityData() override; void GenerateLayerFiles( ODB_TREE_WRITER& writer ); diff --git a/pcbnew/pcb_io/odbpp/pcb_io_odbpp.cpp b/pcbnew/pcb_io/odbpp/pcb_io_odbpp.cpp index e72f514366..660da59dc2 100644 --- a/pcbnew/pcb_io/odbpp/pcb_io_odbpp.cpp +++ b/pcbnew/pcb_io/odbpp/pcb_io_odbpp.cpp @@ -63,9 +63,9 @@ bool PCB_IO_ODBPP::GenerateFiles( ODB_TREE_WRITER& writer ) { for( const auto entity : m_entities ) { - if( !entity->CreateDirectiryTree( writer ) ) + if( !entity->CreateDirectoryTree( writer ) ) { - throw std::runtime_error( "Failed in create directiry tree process" ); + throw std::runtime_error( "Failed in create directory tree process" ); return false; }