kicad2step: Implement overwrite protection, handle 'force overwrite' flag
Fixes: lp:1791826 * https://bugs.launchpad.net/kicad/+bug/1791826
This commit is contained in:
parent
7037e422a8
commit
c120ae9e9d
|
@ -267,6 +267,14 @@ int KICAD2MCAD::OnRun()
|
||||||
tfname.SetExt( getOutputExt() );
|
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();
|
wxString outfile = tfname.GetFullPath();
|
||||||
KICADPCB pcb;
|
KICADPCB pcb;
|
||||||
|
|
||||||
|
@ -289,10 +297,10 @@ int KICAD2MCAD::OnRun()
|
||||||
|
|
||||||
#ifdef SUPPORTS_IGES
|
#ifdef SUPPORTS_IGES
|
||||||
if( m_fmtIGES )
|
if( m_fmtIGES )
|
||||||
res = pcb.WriteIGES( outfile, m_overwrite );
|
res = pcb.WriteIGES( outfile );
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
res = pcb.WriteSTEP( outfile, m_overwrite );
|
res = pcb.WriteSTEP( outfile );
|
||||||
|
|
||||||
if( !res )
|
if( !res )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -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 )
|
if( m_pcb )
|
||||||
{
|
{
|
||||||
std::string filename( aFileName.ToUTF8() );
|
std::string filename( aFileName.ToUTF8() );
|
||||||
return m_pcb->WriteSTEP( filename, aOverwrite );
|
return m_pcb->WriteSTEP( filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -192,12 +192,12 @@ bool KICADPCB::WriteSTEP( const wxString& aFileName, bool aOverwrite )
|
||||||
|
|
||||||
|
|
||||||
#ifdef SUPPORTS_IGES
|
#ifdef SUPPORTS_IGES
|
||||||
bool KICADPCB::WriteIGES( const wxString& aFileName, bool aOverwrite )
|
bool KICADPCB::WriteIGES( const wxString& aFileName )
|
||||||
{
|
{
|
||||||
if( m_pcb )
|
if( m_pcb )
|
||||||
{
|
{
|
||||||
std::string filename( aFileName.ToUTF8() );
|
std::string filename( aFileName.ToUTF8() );
|
||||||
return m_pcb->WriteIGES( filename, aOverwrite );
|
return m_pcb->WriteIGES( filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -108,9 +108,9 @@ public:
|
||||||
|
|
||||||
bool ReadFile( const wxString& aFileName );
|
bool ReadFile( const wxString& aFileName );
|
||||||
bool ComposePCB( bool aComposeVirtual = true );
|
bool ComposePCB( bool aComposeVirtual = true );
|
||||||
bool WriteSTEP( const wxString& aFileName, bool aOverwrite );
|
bool WriteSTEP( const wxString& aFileName );
|
||||||
#ifdef SUPPORTS_IGES
|
#ifdef SUPPORTS_IGES
|
||||||
bool WriteIGES( const wxString& aFileName, bool aOverwrite );
|
bool WriteIGES( const wxString& aFileName );
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -838,7 +838,7 @@ bool PCBMODEL::CreatePCB()
|
||||||
|
|
||||||
#ifdef SUPPORTS_IGES
|
#ifdef SUPPORTS_IGES
|
||||||
// write the assembly model in IGES format
|
// 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() )
|
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
|
// 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() )
|
if( m_pcb_label.IsNull() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -142,11 +142,11 @@ public:
|
||||||
|
|
||||||
#ifdef SUPPORTS_IGES
|
#ifdef SUPPORTS_IGES
|
||||||
// write the assembly model in IGES format
|
// write the assembly model in IGES format
|
||||||
bool WriteIGES( const std::string& aFileName, bool aOverwrite );
|
bool WriteIGES( const std::string& aFileName );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// write the assembly model in STEP format
|
// 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
|
#endif //OCE_VIS_OCE_UTILS_H
|
||||||
|
|
Loading…
Reference in New Issue