42 result.Trim(
true ).Trim(
false );
47 for(
size_t i = 0; i <
result.length(); ++i )
49 const wxUniChar ch =
result[i];
51 if( !( wxIsalnum( ch ) || ch ==
'_' || ch ==
'-' || ch ==
'.' ) )
64 if( prefix.IsEmpty() )
74 if( aPayload.empty() )
76 aError =
_(
"Payload was empty." );
80 wxFileName targetDir = aOutput;
81 targetDir.SetFullName( wxEmptyString );
83 if( !targetDir.DirExists() && !targetDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
85 aError = wxString::Format(
_(
"Unable to create '%s'." ), targetDir.GetFullPath() );
89 wxFFile file( aOutput.GetFullPath(), wxS(
"wb" ) );
91 if( !file.IsOpened() )
93 aError = wxString::Format(
_(
"Unable to open '%s' for writing." ), aOutput.GetFullPath() );
97 if( file.Write( aPayload.data(), aPayload.size() ) != aPayload.size() )
99 aError = wxString::Format(
_(
"Failed to write '%s'." ), aOutput.GetFullPath() );
114 aError =
_(
"Unable to load schematic settings." );
120 if( destination.IsEmpty() )
124 destination.Trim(
true ).Trim(
false );
126 if( destination.IsEmpty() )
128 aError =
_(
"Destination directory is not configured." );
132 wxFileName dir = wxFileName::DirName( destination );
135 if( !dir.DirExists() && !dir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
137 aError = wxString::Format(
_(
"Unable to create directory '%s'." ), dir.GetFullPath() );
147 const wxString& aNickname,
bool aGlobalTable,
bool aStrict,
151 std::optional<LIBRARY_TABLE*> tableOpt = manager.
Table(
158 aError =
_(
"Unable to access the library table." );
164 const wxString fullPath = aLibraryPath.GetFullPath();
166 if(
table->HasRow( aNickname ) )
168 if( std::optional<LIBRARY_TABLE_ROW*> rowOpt =
table->Row( aNickname ); rowOpt )
172 if( row->
URI() != fullPath )
178 aError =
_(
"Failed to update the library table." );
197 aError =
_(
"Failed to save the library table." );
206 const wxString& aLibItemName, wxString& aError )
210 aError =
_(
"No schematic editor is available for placement." );
222 aError =
_(
"Unable to load the downloaded symbol for placement." );
237 aError =
_(
"Unable to access the schematic placement tools." );
virtual void SetParent(EDA_ITEM *aParent)
REMOTE_PROVIDER_SETTINGS m_RemoteSymbol
AUTOPLACE_FIELDS m_AutoplaceFields
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 SetOptions(const wxString &aOptions)
void SetNickname(const wxString &aNickname)
void SetOk(bool aOk=true)
void SetType(const wxString &aType)
void SetDescription(const wxString &aDescription)
void SetURI(const wxString &aUri)
const wxString & URI() const
A logical library item identifier and consists of various portions much like a URI.
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Define a library symbol object.
virtual LIBRARY_MANAGER & GetLibraryManager() const
static TOOL_ACTION placeSymbol
EESCHEMA_SETTINGS * eeconfig() const
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Automatically orient all the fields in the symbol.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global program "get" accessor.
bool PlaceRemoteDownloadedSymbol(SCH_EDIT_FRAME *aFrame, const wxString &aNickname, const wxString &aLibItemName, wxString &aError)
Place a symbol from a remote download into the schematic editor.
bool EnsureRemoteLibraryEntry(LIBRARY_TABLE_TYPE aTableType, const wxFileName &aLibraryPath, const wxString &aNickname, bool aGlobalTable, bool aStrict, wxString &aError)
Add or update a library table entry for a remote download library.
bool WriteRemoteBinaryFile(const wxFileName &aOutput, const std::vector< uint8_t > &aPayload, wxString &aError)
Write binary data to a file, creating parent directories as needed.
bool EnsureRemoteDestinationRoot(wxFileName &aOutDir, wxString &aError)
Resolve and create the configured destination root directory for remote symbol downloads.
wxString RemoteLibraryPrefix()
Return the configured (or default) library prefix for remote downloads, sanitized for use as a filena...
wxString SanitizeRemoteFileComponent(const wxString &aValue, const wxString &aDefault, bool aLower)
Replace non-alphanumeric characters (other than _ - .) with underscores.
T * GetAppSettings(const char *aFilename)
static wxString DefaultLibraryPrefix()
static wxString DefaultDestinationDir()
wxString result
Test unit parsing edge cases and error handling.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().