Add FootprintExists() which can be more careful about FS differences.
(And in particular, MSW's case-insensitive FS.) Fixes: lp:1835999 * https://bugs.launchpad.net/kicad/+bug/1835999
This commit is contained in:
parent
34894acb89
commit
20036f8105
|
@ -341,8 +341,11 @@ bool FP_LIB_TABLE::FootprintExists( const wxString& aNickname, const wxString& a
|
|||
{
|
||||
try
|
||||
{
|
||||
std::unique_ptr<MODULE> m( FootprintLoad( aNickname, aFootprintName ) );
|
||||
return m.get() != nullptr;
|
||||
const FP_LIB_TABLE_ROW* row = FindRow( aNickname );
|
||||
wxASSERT( (PLUGIN*) row->plugin );
|
||||
|
||||
return row->plugin->FootprintExists( row->GetFullURI( true ), aFootprintName,
|
||||
row->GetProperties() );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
|
|
|
@ -420,6 +420,13 @@ public:
|
|||
const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
|
||||
/**
|
||||
* Function FootprintExists
|
||||
* check for the existence of a footprint.
|
||||
*/
|
||||
virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
|
||||
/**
|
||||
* Function FootprintSave
|
||||
* will write @a aModule to an existing library located at @a aLibraryPath.
|
||||
|
|
|
@ -2103,6 +2103,22 @@ const MODULE* PCB_IO::GetEnumeratedFootprint( const wxString& aLibraryPath,
|
|||
}
|
||||
|
||||
|
||||
bool PCB_IO::FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties )
|
||||
{
|
||||
// Note: checking the cache sounds like a good idea, but won't catch files which differ
|
||||
// only in case.
|
||||
//
|
||||
// Since this goes out to the native filesystem, we get platform differences (ie: MSW's
|
||||
// case-insensitive filesystem) handled "for free".
|
||||
|
||||
wxFileName footprintFile( aLibraryPath, aFootprintName );
|
||||
footprintFile.SetExt( KiCadFootprintFileExtension );
|
||||
|
||||
return footprintFile.Exists();
|
||||
}
|
||||
|
||||
|
||||
MODULE* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties )
|
||||
{
|
||||
|
|
|
@ -127,6 +127,9 @@ public:
|
|||
const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
|
|
|
@ -81,6 +81,14 @@ const MODULE* PLUGIN::GetEnumeratedFootprint( const wxString& aLibraryPath,
|
|||
}
|
||||
|
||||
|
||||
bool PLUGIN::FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties )
|
||||
{
|
||||
// default implementation
|
||||
return FootprintLoad( aLibraryPath, aFootprintName, aProperties ) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue