KiCad PCB EDA Suite
|
#include <eda_base_frame.h>
#include <kiplatform/app.h>
#include <project.h>
#include <common.h>
#include <env_vars.h>
#include <reporter.h>
#include <macros.h>
#include <mutex>
#include <wx/config.h>
#include <wx/log.h>
#include <wx/msgdlg.h>
#include <wx/stdpaths.h>
#include <wx/url.h>
#include <wx/utils.h>
Go to the source code of this file.
Enumerations | |
enum | Bracket { Bracket_None , Bracket_Normal = ')' , Bracket_Curly = '}' , Bracket_Max } |
Functions | |
wxString | ExpandTextVars (const wxString &aSource, const PROJECT *aProject) |
wxString | ExpandTextVars (const wxString &aSource, const std::function< bool(wxString *)> *aResolver) |
Expand '${var-name}' templates in text. More... | |
wxString | KIwxExpandEnvVars (const wxString &str, const PROJECT *aProject, std::set< wxString > *aSet=nullptr) |
const wxString | ExpandEnvVarSubstitutions (const wxString &aString, const PROJECT *aProject) |
Replace any environment variable & text variable references with their values. More... | |
const wxString | ResolveUriByEnvVars (const wxString &aUri, PROJECT *aProject) |
Replace any environment and/or text variables in file-path uris (leaving network-path URIs alone). More... | |
bool | EnsureFileDirectoryExists (wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter) |
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist. More... | |
bool | matchWild (const char *pat, const char *text, bool dot_special) |
Performance enhancements to file and directory operations. More... | |
long long | TimestampDir (const wxString &aDirPath, const wxString &aFilespec) |
A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function private to src/common/filename.cpp. More... | |
bool | WarnUserIfOperatingSystemUnsupported () |
Checks if the operating system is explicitly unsupported and displays a disclaimer message box. More... | |
enum Bracket |
Enumerator | |
---|---|
Bracket_None | |
Bracket_Normal | |
Bracket_Curly | |
Bracket_Max |
Definition at line 46 of file common.cpp.
bool EnsureFileDirectoryExists | ( | wxFileName * | aTargetFullFileName, |
const wxString & | aBaseFilename, | ||
REPORTER * | aReporter = nullptr |
||
) |
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
aTargetFullFileName | the wxFileName containing the full path and file name to modify. The path may be absolute or relative to aBaseFilename . |
aBaseFilename | a full filename. Only its path is used to set the aTargetFullFileName path. |
aReporter | a point to a REPORTER object use to show messages (can be NULL) |
Definition at line 327 of file common.cpp.
References _, REPORTER::Report(), RPT_SEVERITY_ERROR, and RPT_SEVERITY_INFO.
Referenced by DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles(), DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles(), SCH_PLOTTER::createPlotFileName(), DIALOG_EXPORT_SVG::ExportSVGFile(), DIALOG_GENDRILL::GenDrillAndMapFiles(), PLOT_CONTROLLER::OpenPlotfile(), and DIALOG_PLOT::Plot().
const wxString ExpandEnvVarSubstitutions | ( | const wxString & | aString, |
const PROJECT * | aProject | ||
) |
Replace any environment variable & text variable references with their values.
aString | a string containing (perhaps) references to env var |
Definition at line 299 of file common.cpp.
References KIwxExpandEnvVars().
Referenced by FILENAME_RESOLVER::addPath(), FILENAME_RESOLVER::checkEnvVarPath(), S3D_PLUGIN_MANAGER::checkPluginName(), DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles(), DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles(), FILENAME_RESOLVER::createPathList(), DIALOG_EXPORT_SVG::ExportSVGFile(), DIALOG_GENDRILL::GenDrillAndMapFiles(), LIB_TABLE_ROW::GetFullURI(), DIALOG_PLOT_SCHEMATIC::getOutputPath(), TEXT_BUTTON_FILE_BROWSER::OnButtonClick(), PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries(), DIALOG_GENDRILL::OnGenReportFile(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_EXPORT_SVG::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_PAGES_SETTINGS::OnWksFileSelection(), PLOT_CONTROLLER::OpenPlotfile(), DIALOG_PLOT::Plot(), SIM_LIB_MGR::ResolveLibraryPath(), FILENAME_RESOLVER::ResolvePath(), DS_DATA_MODEL::ResolvePath(), ResolveUriByEnvVars(), S3D_CACHE::Set3DConfigDir(), FILENAME_RESOLVER::Set3DConfigDir(), FILENAME_RESOLVER::SetProject(), FILENAME_RESOLVER::ShortenPath(), ERC_TESTER::TestTextVars(), and NETLIST_EXPORTER_SPICE::writeInclude().
wxString ExpandTextVars | ( | const wxString & | aSource, |
const PROJECT * | aProject | ||
) |
Definition at line 58 of file common.cpp.
References ExpandTextVars(), and PROJECT::TextVarResolver().
Referenced by AddGerberX2Header(), GERBER_JOBFILE_WRITER::addJSONGeneralSpecs(), DS_DRAW_ITEM_LIST::BuildFullText(), DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles(), DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles(), CreateHeaderInfoData(), SCH_PLOTTER::createPDFFile(), KIGFX::expandLibItemTextVars(), ExpandTextVars(), DIALOG_EXPORT_SVG::ExportSVGFile(), DIALOG_GENDRILL::GenDrillAndMapFiles(), DIALOG_PLOT_SCHEMATIC::getOutputPath(), SCH_FIELD::GetShownText(), SCH_LABEL_BASE::GetShownText(), SCH_TEXT::GetShownText(), SCH_TEXTBOX::GetShownText(), FP_TEXT::GetShownText(), FP_TEXTBOX::GetShownText(), PCB_TEXT::GetShownText(), PCB_TEXTBOX::GetShownText(), NETLIST_EXPORTER_XML::makeDesignHeader(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), PLOT_CONTROLLER::OpenPlotfile(), DIALOG_PLOT::Plot(), ResolveUriByEnvVars(), and TITLE_BLOCK::TextVarResolver().
wxString ExpandTextVars | ( | const wxString & | aSource, |
const std::function< bool(wxString *)> * | aResolver | ||
) |
Expand '${var-name}' templates in text.
Definition at line 70 of file common.cpp.
wxString KIwxExpandEnvVars | ( | const wxString & | str, |
const PROJECT * | aProject, | ||
std::set< wxString > * | aSet = nullptr |
||
) |
Definition at line 118 of file common.cpp.
References _, Bracket_Curly, Bracket_None, Bracket_Normal, ENV_VAR::GetPredefinedEnvVars(), KI_FALLTHROUGH, KIwxExpandEnvVars(), and PROJECT::TextVarResolver().
Referenced by ExpandEnvVarSubstitutions(), and KIwxExpandEnvVars().
bool matchWild | ( | const char * | pat, |
const char * | text, | ||
bool | dot_special | ||
) |
Performance enhancements to file and directory operations.
Note: while it's annoying to have to make copies of wxWidgets stuff and then add platform-specific performance optimizations, the following routines offer SIGNIFICANT performance benefits. A copy of wxMatchWild(), which wxWidgets attributes to Douglas A. Lewis dalew[email protected][email protected][email protected]s.Buf[email protected]falo[email protected].EDU and ircII's reg.c.
This version is modified to skip any encoding conversions (for performance).
Definition at line 394 of file common.cpp.
References text.
Referenced by TimestampDir().
const wxString ResolveUriByEnvVars | ( | const wxString & | aUri, |
PROJECT * | aProject | ||
) |
Replace any environment and/or text variables in file-path uris (leaving network-path URIs alone).
Definition at line 312 of file common.cpp.
References ExpandEnvVarSubstitutions(), and ExpandTextVars().
Referenced by GetAssociatedDocument().
long long TimestampDir | ( | const wxString & | aDirPath, |
const wxString & | aFilespec | ||
) |
A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function private to src/common/filename.cpp.
This routine offers SIGNIFICANT performance benefits over using wxWidgets to gather timestamps from matching files in a directory.
aDirPath | is the directory to search. |
aFilespec | is a (wildcarded) file spec to match against. |
Definition at line 536 of file common.cpp.
References matchWild().
Referenced by GPCB_FPL_CACHE::GetTimestamp(), and FP_CACHE::GetTimestamp().
bool WarnUserIfOperatingSystemUnsupported | ( | ) |
Checks if the operating system is explicitly unsupported and displays a disclaimer message box.
Definition at line 635 of file common.cpp.
References _, and KIPLATFORM::APP::IsOperatingSystemUnsupported().
Referenced by PGM_BASE::InitPgm(), and COMMON_CONTROL::ReportBug().