23#include <wx/filename.h>
37 const std::vector<wxString>& aLibraries,
REPORTER& aReporter )
39 std::vector<wxString> added;
41 if( aLibraries.empty() )
48 wxCHECK_MSG( adapter && optTable.has_value(), added,
"Could not load symbol lib table." );
53 for(
const wxString& file : aLibraries )
58 wxFileName fn( file );
61 if( !fn.FileExists() && !wxDirExists( fn.GetFullPath() ) )
66 if( type == SCH_IO_MGR::SCH_FILE_UNKNOWN )
68 wxLogTrace(
"KIWAY",
"Unknown file type: %s", fn.GetFullPath() );
74 wxFileName relFn( fn );
75 bool isProjectLocal = !aSourceProjectDir.IsEmpty() && relFn.MakeRelativeTo( aSourceProjectDir )
76 && !relFn.IsAbsolute() && !relFn.GetFullPath().StartsWith( wxS(
".." ) );
83 if( !fn.FileExists() )
86 wxFileName projectFn( projectPath, fn.GetFullName() );
88 if( fn.GetFullPath() != projectFn.GetFullPath() && !projectFn.FileExists()
89 && !wxCopyFile( fn.GetFullPath(), projectFn.GetFullPath(),
false ) )
91 aReporter.
Report( wxString::Format(
_(
"Error copying symbol library '%s'." ), fn.GetFullPath() ),
96 libTableUri = wxS(
"${KIPRJMOD}/" ) + fn.GetFullName();
101 libTableUri = fn.GetFullPath();
104 if( !
table->HasRow( fn.GetName() ) )
108 row.
SetURI( libTableUri );
110 added.emplace_back( fn.GetName() );
119 table->Save().map_error(
122 aReporter.
Report(
_(
"Error saving project library table:\n\n" ) + aError.
message,
133 for(
const wxString& nick : added )
std::optional< LIBRARY_TABLE * > Table(LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope)
Retrieves a given table; creating a new empty project table if a valid project is loaded and the give...
void AbortAsyncLoads()
Abort any async library loading operations in progress.
void LoadProjectTables(std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={})
(Re)loads the project library tables in the given list, or all tables if no list is given
void SetNickname(const wxString &aNickname)
void SetType(const wxString &aType)
void SetURI(const wxString &aUri)
virtual LIBRARY_MANAGER & GetLibraryManager() const
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
Container for project specific data.
virtual const wxString GetProjectPath() const
Return the full path of the project.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
std::optional< LIB_STATUS > LoadOne(LIB_DATA *aLib) override
Loads or reloads the given library, if it exists.
std::vector< wxString > RegisterLocalSymbolLibraries(PROJECT &aProject, const wxString &aSourceProjectDir, const std::vector< wxString > &aLibraries, REPORTER &aReporter)
Register the symbol libraries a source project names in the project symbol library table.
PGM_BASE & Pgm()
The global program "get" accessor.