Improve directory handling for Project Save As.
1) don't change directory names that we don't recognize 2) when we do, make sure the child files get copied to the changed name. Fixes https://gitlab.com/kicad/code/kicad/issues/3834
This commit is contained in:
parent
b56998925b
commit
a04fdf64da
|
@ -138,14 +138,13 @@ const std::string DrillFileExtension( "drl" );
|
||||||
const std::string SVGFileExtension( "svg" );
|
const std::string SVGFileExtension( "svg" );
|
||||||
const std::string ReportFileExtension( "rpt" );
|
const std::string ReportFileExtension( "rpt" );
|
||||||
const std::string FootprintPlaceFileExtension( "pos" );
|
const std::string FootprintPlaceFileExtension( "pos" );
|
||||||
const std::string KiCadLib3DShapesPathExtension( "3dshapes" ); ///< 3D shapes default libpath
|
|
||||||
|
|
||||||
const std::string KiCadFootprintLibPathExtension( "pretty" ); ///< KICAD PLUGIN libpath
|
const std::string KiCadFootprintLibPathExtension( "pretty" ); // this is a directory
|
||||||
const std::string LegacyFootprintLibPathExtension( "mod" );
|
const std::string LegacyFootprintLibPathExtension( "mod" ); // this is a file
|
||||||
const std::string EagleFootprintLibPathExtension( "lbr" );
|
const std::string EagleFootprintLibPathExtension( "lbr" ); // this is a file
|
||||||
|
const std::string GedaPcbFootprintLibFileExtension( "fp" ); // this is a file
|
||||||
|
|
||||||
const std::string KiCadFootprintFileExtension( "kicad_mod" );
|
const std::string KiCadFootprintFileExtension( "kicad_mod" );
|
||||||
const std::string GedaPcbFootprintLibFileExtension( "fp" );
|
|
||||||
const std::string SpecctraDsnFileExtension( "dsn" );
|
const std::string SpecctraDsnFileExtension( "dsn" );
|
||||||
const std::string IpcD356FileExtension( "d356" );
|
const std::string IpcD356FileExtension( "d356" );
|
||||||
|
|
||||||
|
|
|
@ -314,14 +314,23 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
|
||||||
const wxString& aSrcFilePath, wxString& aErrors )
|
const wxString& aSrcFilePath, wxString& aErrors )
|
||||||
{
|
{
|
||||||
wxFileName destFile( aSrcFilePath );
|
wxFileName destFile( aSrcFilePath );
|
||||||
wxString destPath = destFile.GetPath();
|
wxString destPath = destFile.GetPathWithSep();
|
||||||
|
wxUniChar pathSep = wxFileName::GetPathSeparator();
|
||||||
wxString ext = destFile.GetExt();
|
wxString ext = destFile.GetExt();
|
||||||
|
|
||||||
if( destPath.StartsWith( aProjectBasePath ) )
|
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
|
||||||
{
|
|
||||||
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
||||||
destFile.SetPath( destPath );
|
|
||||||
}
|
#if 0
|
||||||
|
// WAYNE STAMBAUGH TODO:
|
||||||
|
// If we end up with a symbol equivalent to ".pretty" we'll want to handle it here....
|
||||||
|
wxString srcProjectSymbolLib = pathSep + aProjectName + ".sym_lib_dir_extension" + pathSep;
|
||||||
|
wxString newProjectSymbolLib = pathSep + aNewProjectName + ".sym_lib_dir_extension" + pathSep;
|
||||||
|
|
||||||
|
destPath.Replace( srcProjectSymbolLib, newProjectSymbolLib, true );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
destFile.SetPath( destPath );
|
||||||
|
|
||||||
if( ext == "sch" || ext == "sch-bak" )
|
if( ext == "sch" || ext == "sch-bak" )
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,10 +149,11 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
|
||||||
const wxString& aSrcFilePath, wxString& aErrors )
|
const wxString& aSrcFilePath, wxString& aErrors )
|
||||||
{
|
{
|
||||||
wxFileName destFile( aSrcFilePath );
|
wxFileName destFile( aSrcFilePath );
|
||||||
wxString destPath = destFile.GetPath();
|
wxString destPath = destFile.GetPathWithSep();
|
||||||
|
wxUniChar pathSep = wxFileName::GetPathSeparator();
|
||||||
wxString ext = destFile.GetExt();
|
wxString ext = destFile.GetExt();
|
||||||
|
|
||||||
if( destPath.StartsWith( aProjectBasePath ) )
|
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
|
||||||
{
|
{
|
||||||
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
||||||
destFile.SetPath( destPath );
|
destFile.SetPath( destPath );
|
||||||
|
|
|
@ -141,7 +141,6 @@ extern const std::string GedaPcbFootprintLibFileExtension;
|
||||||
extern const std::string EagleFootprintLibPathExtension;
|
extern const std::string EagleFootprintLibPathExtension;
|
||||||
extern const std::string ComponentFileExtension;
|
extern const std::string ComponentFileExtension;
|
||||||
extern const std::string PageLayoutDescrFileExtension;
|
extern const std::string PageLayoutDescrFileExtension;
|
||||||
extern const std::string KiCadLib3DShapesPathExtension;
|
|
||||||
extern const std::string SpecctraDsnFileExtension;
|
extern const std::string SpecctraDsnFileExtension;
|
||||||
extern const std::string IpcD356FileExtension;
|
extern const std::string IpcD356FileExtension;
|
||||||
|
|
||||||
|
|
|
@ -437,7 +437,6 @@ public:
|
||||||
KiCadFootprintLibPathExtension;
|
KiCadFootprintLibPathExtension;
|
||||||
GedaPcbFootprintLibFileExtension;
|
GedaPcbFootprintLibFileExtension;
|
||||||
EagleFootprintLibPathExtension;
|
EagleFootprintLibPathExtension;
|
||||||
KiCadLib3DShapesPathExtension;
|
|
||||||
SpecctraDsnFileExtension;
|
SpecctraDsnFileExtension;
|
||||||
IpcD356FileExtension;
|
IpcD356FileExtension;
|
||||||
*/
|
*/
|
||||||
|
@ -448,16 +447,26 @@ public:
|
||||||
virtual wxDirTraverseResult OnDir( const wxString& dirPath ) override
|
virtual wxDirTraverseResult OnDir( const wxString& dirPath ) override
|
||||||
{
|
{
|
||||||
wxFileName destDir( dirPath );
|
wxFileName destDir( dirPath );
|
||||||
wxString destDirPath = destDir.GetPath(); // strips off last directory
|
wxString destDirPath = destDir.GetPathWithSep();
|
||||||
|
wxUniChar pathSep = wxFileName::GetPathSeparator();
|
||||||
|
|
||||||
if( destDirPath.StartsWith( m_projectDirPath ) )
|
if( destDirPath.StartsWith( m_projectDirPath + pathSep ) )
|
||||||
{
|
{
|
||||||
destDirPath.Replace( m_projectDirPath, m_newProjectDirPath, false );
|
destDirPath.Replace( m_projectDirPath, m_newProjectDirPath, false );
|
||||||
destDir.SetPath( destDirPath );
|
destDir.SetPath( destDirPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( destDir.GetName() == m_projectName )
|
if( destDir.GetName() == m_projectName )
|
||||||
destDir.SetName( m_newProjectName );
|
{
|
||||||
|
if( destDir.GetExt() == "pretty" )
|
||||||
|
destDir.SetName( m_newProjectName );
|
||||||
|
#if 0
|
||||||
|
// WAYNE STAMBAUGH TODO:
|
||||||
|
// If we end up with a symbol equivalent to ".pretty" we'll want to handle it here....
|
||||||
|
else if( destDir.GetExt() == "sym_lib_dir_extension" )
|
||||||
|
destDir.SetName( m_newProjectName );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if( !wxMkdir( destDir.GetFullPath() ) )
|
if( !wxMkdir( destDir.GetFullPath() ) )
|
||||||
{
|
{
|
||||||
|
@ -466,7 +475,7 @@ public:
|
||||||
if( !m_errors.empty() )
|
if( !m_errors.empty() )
|
||||||
m_errors += "\n";
|
m_errors += "\n";
|
||||||
|
|
||||||
msg.Printf( _( "Cannot copy file \"%s\"." ), destDir.GetFullPath() );
|
msg.Printf( _( "Cannot copy folder \"%s\"." ), destDir.GetFullPath() );
|
||||||
m_errors += msg;
|
m_errors += msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,10 +141,11 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aSrcPr
|
||||||
const wxString& aSrcFilePath, wxString& aErrors )
|
const wxString& aSrcFilePath, wxString& aErrors )
|
||||||
{
|
{
|
||||||
wxFileName destFile( aSrcFilePath );
|
wxFileName destFile( aSrcFilePath );
|
||||||
wxString destPath = destFile.GetPath();
|
wxString destPath = destFile.GetPathWithSep();
|
||||||
|
wxUniChar pathSep = wxFileName::GetPathSeparator();
|
||||||
wxString ext = destFile.GetExt();
|
wxString ext = destFile.GetExt();
|
||||||
|
|
||||||
if( destPath.StartsWith( aProjectBasePath ) )
|
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
|
||||||
{
|
{
|
||||||
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
||||||
destFile.SetPath( destPath );
|
destFile.SetPath( destPath );
|
||||||
|
|
|
@ -384,14 +384,19 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aSrcPr
|
||||||
const wxString& aSrcFilePath, wxString& aErrors )
|
const wxString& aSrcFilePath, wxString& aErrors )
|
||||||
{
|
{
|
||||||
wxFileName destFile( aSrcFilePath );
|
wxFileName destFile( aSrcFilePath );
|
||||||
wxString destPath = destFile.GetPath();
|
wxString destPath = destFile.GetPathWithSep();
|
||||||
|
wxUniChar pathSep = wxFileName::GetPathSeparator();
|
||||||
wxString ext = destFile.GetExt();
|
wxString ext = destFile.GetExt();
|
||||||
|
|
||||||
if( destPath.StartsWith( aProjectBasePath ) )
|
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
|
||||||
{
|
|
||||||
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
||||||
destFile.SetPath( destPath );
|
|
||||||
}
|
wxString srcProjectFootprintLib = pathSep + aSrcProjectName + ".pretty" + pathSep;
|
||||||
|
wxString newProjectFootprintLib = pathSep + aNewProjectName + ".pretty" + pathSep;
|
||||||
|
|
||||||
|
destPath.Replace( srcProjectFootprintLib, newProjectFootprintLib, true );
|
||||||
|
|
||||||
|
destFile.SetPath( destPath );
|
||||||
|
|
||||||
if( ext == "kicad_pcb" || ext == "kicad_pcb-bak" )
|
if( ext == "kicad_pcb" || ext == "kicad_pcb-bak" )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue