kicad2step: Implement overwrite protection, handle 'force overwrite' flag

Fixes: lp:1791826
* https://bugs.launchpad.net/kicad/+bug/1791826
This commit is contained in:
Maciej Suminski 2018-09-11 09:23:11 +02:00
parent 7037e422a8
commit c120ae9e9d
5 changed files with 20 additions and 12 deletions

View File

@ -267,6 +267,14 @@ int KICAD2MCAD::OnRun()
tfname.SetExt( getOutputExt() );
}
if( tfname.FileExists() && !m_overwrite )
{
std::cerr << "** Output already exists. "
<< "Enable the force overwrite flag to overwrite it." << std::endl;
return -1;
}
wxString outfile = tfname.GetFullPath();
KICADPCB pcb;
@ -289,10 +297,10 @@ int KICAD2MCAD::OnRun()
#ifdef SUPPORTS_IGES
if( m_fmtIGES )
res = pcb.WriteIGES( outfile, m_overwrite );
res = pcb.WriteIGES( outfile );
else
#endif
res = pcb.WriteSTEP( outfile, m_overwrite );
res = pcb.WriteSTEP( outfile );
if( !res )
return -1;

View File

@ -179,12 +179,12 @@ bool KICADPCB::ReadFile( const wxString& aFileName )
}
bool KICADPCB::WriteSTEP( const wxString& aFileName, bool aOverwrite )
bool KICADPCB::WriteSTEP( const wxString& aFileName )
{
if( m_pcb )
{
std::string filename( aFileName.ToUTF8() );
return m_pcb->WriteSTEP( filename, aOverwrite );
return m_pcb->WriteSTEP( filename );
}
return false;
@ -192,12 +192,12 @@ bool KICADPCB::WriteSTEP( const wxString& aFileName, bool aOverwrite )
#ifdef SUPPORTS_IGES
bool KICADPCB::WriteIGES( const wxString& aFileName, bool aOverwrite )
bool KICADPCB::WriteIGES( const wxString& aFileName )
{
if( m_pcb )
{
std::string filename( aFileName.ToUTF8() );
return m_pcb->WriteIGES( filename, aOverwrite );
return m_pcb->WriteIGES( filename );
}
return false;

View File

@ -108,9 +108,9 @@ public:
bool ReadFile( const wxString& aFileName );
bool ComposePCB( bool aComposeVirtual = true );
bool WriteSTEP( const wxString& aFileName, bool aOverwrite );
bool WriteSTEP( const wxString& aFileName );
#ifdef SUPPORTS_IGES
bool WriteIGES( const wxString& aFileName, bool aOverwrite );
bool WriteIGES( const wxString& aFileName );
#endif
};

View File

@ -838,7 +838,7 @@ bool PCBMODEL::CreatePCB()
#ifdef SUPPORTS_IGES
// write the assembly model in IGES format
bool PCBMODEL::WriteIGES( const std::string& aFileName, bool aOverwrite )
bool PCBMODEL::WriteIGES( const std::string& aFileName )
{
if( m_pcb_label.IsNull() )
{
@ -872,7 +872,7 @@ bool PCBMODEL::WriteIGES( const std::string& aFileName, bool aOverwrite )
// write the assembly model in STEP format
bool PCBMODEL::WriteSTEP( const std::string& aFileName, bool aOverwrite )
bool PCBMODEL::WriteSTEP( const std::string& aFileName )
{
if( m_pcb_label.IsNull() )
{

View File

@ -142,11 +142,11 @@ public:
#ifdef SUPPORTS_IGES
// write the assembly model in IGES format
bool WriteIGES( const std::string& aFileName, bool aOverwrite );
bool WriteIGES( const std::string& aFileName );
#endif
// write the assembly model in STEP format
bool WriteSTEP( const std::string& aFileName, bool aOverwrite );
bool WriteSTEP( const std::string& aFileName );
};
#endif //OCE_VIS_OCE_UTILS_H