Browse Source

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
pull/16/head
Jeff Young 6 years ago
parent
commit
a04fdf64da
  1. 9
      common/wildcards_and_files_ext.cpp
  2. 19
      eeschema/eeschema.cpp
  3. 5
      gerbview/gerbview.cpp
  4. 1
      include/wildcards_and_files_ext.h
  5. 19
      kicad/tools/kicad_manager_control.cpp
  6. 5
      pagelayout_editor/pl_editor.cpp
  7. 15
      pcbnew/pcbnew.cpp

9
common/wildcards_and_files_ext.cpp

@ -138,14 +138,13 @@ const std::string DrillFileExtension( "drl" );
const std::string SVGFileExtension( "svg" );
const std::string ReportFileExtension( "rpt" );
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 LegacyFootprintLibPathExtension( "mod" );
const std::string EagleFootprintLibPathExtension( "lbr" );
const std::string KiCadFootprintLibPathExtension( "pretty" ); // this is a directory
const std::string LegacyFootprintLibPathExtension( "mod" ); // this is a file
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 GedaPcbFootprintLibFileExtension( "fp" );
const std::string SpecctraDsnFileExtension( "dsn" );
const std::string IpcD356FileExtension( "d356" );

19
eeschema/eeschema.cpp

@ -314,14 +314,23 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
const wxString& aSrcFilePath, wxString& aErrors )
{
wxFileName destFile( aSrcFilePath );
wxString destPath = destFile.GetPath();
wxString destPath = destFile.GetPathWithSep();
wxUniChar pathSep = wxFileName::GetPathSeparator();
wxString ext = destFile.GetExt();
if( destPath.StartsWith( aProjectBasePath ) )
{
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
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" )
{

5
gerbview/gerbview.cpp

@ -149,10 +149,11 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
const wxString& aSrcFilePath, wxString& aErrors )
{
wxFileName destFile( aSrcFilePath );
wxString destPath = destFile.GetPath();
wxString destPath = destFile.GetPathWithSep();
wxUniChar pathSep = wxFileName::GetPathSeparator();
wxString ext = destFile.GetExt();
if( destPath.StartsWith( aProjectBasePath ) )
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
{
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
destFile.SetPath( destPath );

1
include/wildcards_and_files_ext.h

@ -141,7 +141,6 @@ extern const std::string GedaPcbFootprintLibFileExtension;
extern const std::string EagleFootprintLibPathExtension;
extern const std::string ComponentFileExtension;
extern const std::string PageLayoutDescrFileExtension;
extern const std::string KiCadLib3DShapesPathExtension;
extern const std::string SpecctraDsnFileExtension;
extern const std::string IpcD356FileExtension;

19
kicad/tools/kicad_manager_control.cpp

@ -437,7 +437,6 @@ public:
KiCadFootprintLibPathExtension;
GedaPcbFootprintLibFileExtension;
EagleFootprintLibPathExtension;
KiCadLib3DShapesPathExtension;
SpecctraDsnFileExtension;
IpcD356FileExtension;
*/
@ -448,16 +447,26 @@ public:
virtual wxDirTraverseResult OnDir( const wxString& dirPath ) override
{
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 );
destDir.SetPath( destDirPath );
}
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() ) )
{
@ -466,7 +475,7 @@ public:
if( !m_errors.empty() )
m_errors += "\n";
msg.Printf( _( "Cannot copy file \"%s\"." ), destDir.GetFullPath() );
msg.Printf( _( "Cannot copy folder \"%s\"." ), destDir.GetFullPath() );
m_errors += msg;
}

5
pagelayout_editor/pl_editor.cpp

@ -141,10 +141,11 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aSrcPr
const wxString& aSrcFilePath, wxString& aErrors )
{
wxFileName destFile( aSrcFilePath );
wxString destPath = destFile.GetPath();
wxString destPath = destFile.GetPathWithSep();
wxUniChar pathSep = wxFileName::GetPathSeparator();
wxString ext = destFile.GetExt();
if( destPath.StartsWith( aProjectBasePath ) )
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
{
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
destFile.SetPath( destPath );

15
pcbnew/pcbnew.cpp

@ -384,14 +384,19 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aSrcPr
const wxString& aSrcFilePath, wxString& aErrors )
{
wxFileName destFile( aSrcFilePath );
wxString destPath = destFile.GetPath();
wxString destPath = destFile.GetPathWithSep();
wxUniChar pathSep = wxFileName::GetPathSeparator();
wxString ext = destFile.GetExt();
if( destPath.StartsWith( aProjectBasePath ) )
{
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
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" )
{

Loading…
Cancel
Save