KiCad PCB EDA Suite
PATHS Class Reference

Helper class to centralize the paths used throughout kicad. More...

#include <paths.h>

Static Public Member Functions

static wxString GetUserScriptingPath ()
 Gets the user path for python scripts. More...
 
static wxString GetUserTemplatesPath ()
 Gets the user path for custom templates. More...
 
static wxString GetUserPluginsPath ()
 Gets the user path for plugins. More...
 
static wxString GetUserPlugins3DPath ()
 Gets the user path for 3d viewer plugin. More...
 
static wxString GetDefaultUserProjectsPath ()
 Gets the default path we point users to create projects. More...
 
static wxString GetDefaultUserSymbolsPath ()
 Gets the default path we point users to create projects. More...
 
static wxString GetDefaultUserFootprintsPath ()
 Gets the default path we point users to create projects. More...
 
static wxString GetDefaultUser3DModelsPath ()
 Gets the default path we point users to create projects. More...
 
static wxString GetStockDataPath (bool aRespectRunFromBuildDir=true)
 Gets the stock (install) data path, which is the base path for things like scripting, etc. More...
 
static wxString GetStockEDALibraryPath ()
 Gets the stock (install) EDA library data path, which is the base path for templates, schematic symbols, footprints, and 3D models. More...
 
static wxString GetDefault3rdPartyPath ()
 Gets the default path for PCM packages. More...
 
static wxString GetStockSymbolsPath ()
 Gets the stock (install) symbols path. More...
 
static wxString GetStockFootprintsPath ()
 Gets the stock (install) footprints path. More...
 
static wxString GetStock3dmodelsPath ()
 Gets the stock (install) 3dmodels path. More...
 
static wxString GetStockScriptingPath ()
 Gets the stock (install) scripting path. More...
 
static wxString GetStockPluginsPath ()
 Gets the stock (install) plugins path. More...
 
static wxString GetStockPlugins3DPath ()
 Gets the stock (install) 3d viewer plugins path. More...
 
static wxString GetStockDemosPath ()
 Gets the stock (install) demos path. More...
 
static wxString GetStockTemplatesPath ()
 Gets the stock (install) templates path. More...
 
static wxString GetLocaleDataPath ()
 Gets the locales translation data path. More...
 
static wxString GetUserCachePath ()
 Gets the stock (install) 3d viewer plugins path. More...
 
static wxString GetDocumentationPath ()
 Gets the documentation path, which is the base path for help files. More...
 
static bool EnsurePathExists (const wxString &aPath)
 Attempts to create a given path if it does not exist. More...
 
static void EnsureUserPathsExist ()
 Ensures/creates user default paths. More...
 

Private Member Functions

 PATHS ()
 

Static Private Member Functions

static void getUserDocumentPath (wxFileName &aPath)
 Gets the user path for the current kicad version which acts as the root for other user paths. More...
 

Detailed Description

Helper class to centralize the paths used throughout kicad.

Definition at line 29 of file paths.h.

Constructor & Destructor Documentation

◆ PATHS()

PATHS::PATHS ( )
inlineprivate

Definition at line 175 of file paths.h.

175{}

Member Function Documentation

◆ EnsurePathExists()

bool PATHS::EnsurePathExists ( const wxString &  aPath)
static

Attempts to create a given path if it does not exist.

Definition at line 349 of file paths.cpp.

350{
351 wxFileName path( aPath );
352 if( !path.MakeAbsolute() )
353 {
354 return false;
355 }
356
357 if( !wxFileName::DirExists( aPath ) )
358 {
359 if( !wxFileName::Mkdir( aPath, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
360 {
361 return false;
362 }
363 }
364
365 return true;
366}

References path.

Referenced by EnsureUserPathsExist().

◆ EnsureUserPathsExist()

void PATHS::EnsureUserPathsExist ( )
static

Ensures/creates user default paths.

Definition at line 369 of file paths.cpp.

370{
381}
static wxString GetUserPluginsPath()
Gets the user path for plugins.
Definition: paths.cpp:53
static wxString GetDefaultUser3DModelsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:119
static wxString GetUserTemplatesPath()
Gets the user path for custom templates.
Definition: paths.cpp:86
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:139
static wxString GetUserPlugins3DPath()
Gets the user path for 3d viewer plugin.
Definition: paths.cpp:64
static bool EnsurePathExists(const wxString &aPath)
Attempts to create a given path if it does not exist.
Definition: paths.cpp:349
static wxString GetDefault3rdPartyPath()
Gets the default path for PCM packages.
Definition: paths.cpp:129
static wxString GetDefaultUserFootprintsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:108
static wxString GetUserCachePath()
Gets the stock (install) 3d viewer plugins path.
Definition: paths.cpp:321
static wxString GetUserScriptingPath()
Gets the user path for python scripts.
Definition: paths.cpp:75
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:97

References EnsurePathExists(), GetDefault3rdPartyPath(), GetDefaultUser3DModelsPath(), GetDefaultUserFootprintsPath(), GetDefaultUserProjectsPath(), GetDefaultUserSymbolsPath(), GetUserCachePath(), GetUserPlugins3DPath(), GetUserPluginsPath(), GetUserScriptingPath(), and GetUserTemplatesPath().

Referenced by PGM_BASE::InitPgm().

◆ GetDefault3rdPartyPath()

wxString PATHS::GetDefault3rdPartyPath ( )
static

Gets the default path for PCM packages.

Definition at line 129 of file paths.cpp.

130{
131 wxFileName tmp;
132 getUserDocumentPath( tmp );
133
134 tmp.AppendDir( wxT( "3rdparty" ) );
135
136 return tmp.GetPath();
137}
static void getUserDocumentPath(wxFileName &aPath)
Gets the user path for the current kicad version which acts as the root for other user paths.
Definition: paths.cpp:39

References getUserDocumentPath().

Referenced by EnsureUserPathsExist(), COMMON_SETTINGS::InitializeEnvironment(), SETTINGS_MANAGER::loadAllColorSettings(), and PLUGIN_CONTENT_MANAGER::ReadEnvVar().

◆ GetDefaultUser3DModelsPath()

wxString PATHS::GetDefaultUser3DModelsPath ( )
static

Gets the default path we point users to create projects.

Definition at line 119 of file paths.cpp.

120{
121 wxFileName tmp;
122 getUserDocumentPath( tmp );
123
124 tmp.AppendDir( wxT( "3dmodels" ) );
125
126 return tmp.GetPath();
127}

References getUserDocumentPath().

Referenced by EnsureUserPathsExist().

◆ GetDefaultUserFootprintsPath()

wxString PATHS::GetDefaultUserFootprintsPath ( )
static

Gets the default path we point users to create projects.

Definition at line 108 of file paths.cpp.

109{
110 wxFileName tmp;
111 getUserDocumentPath( tmp );
112
113 tmp.AppendDir( wxT( "footprints" ) );
114
115 return tmp.GetPath();
116}

References getUserDocumentPath().

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), PCB_BASE_EDIT_FRAME::createNewLibrary(), EnsureUserPathsExist(), and PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE().

◆ GetDefaultUserProjectsPath()

wxString PATHS::GetDefaultUserProjectsPath ( )
static

Gets the default path we point users to create projects.

Definition at line 139 of file paths.cpp.

140{
141 wxFileName tmp;
142 getUserDocumentPath( tmp );
143
144 tmp.AppendDir( wxT( "projects" ) );
145
146 return tmp.GetPath();
147}

References getUserDocumentPath().

Referenced by AskLoadBoardFileName(), EDA_BASE_FRAME::commonInit(), PCB_EDIT_FRAME::doAutoSave(), EnsureUserPathsExist(), PCB_EDIT_FRAME::Files_io_from_id(), DIALOG_GENDRILL::OnGenReportFile(), PROJECT_TREE_PANE::onOpenDirectory(), PROJECT_TREE_PANE::ReCreateTreePrj(), and SCH_EDIT_FRAME::SaveProject().

◆ GetDefaultUserSymbolsPath()

wxString PATHS::GetDefaultUserSymbolsPath ( )
static

Gets the default path we point users to create projects.

Definition at line 97 of file paths.cpp.

98{
99 wxFileName tmp;
100 getUserDocumentPath( tmp );
101
102 tmp.AppendDir( wxT( "symbols" ) );
103
104 return tmp.GetPath();
105}

References getUserDocumentPath().

Referenced by SYMBOL_EDIT_FRAME::AddLibraryFile(), EnsureUserPathsExist(), SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), and PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE().

◆ GetDocumentationPath()

wxString PATHS::GetDocumentationPath ( )
static

Gets the documentation path, which is the base path for help files.

Definition at line 333 of file paths.cpp.

334{
335 wxString path;
336
337#if defined( __WXMAC__ )
338 path = GetOSXKicadDataDir();
339#elif defined( __WXMSW__ )
340 path = getWindowsKiCadRoot() + wxT( "share/doc/kicad" );
341#else
342 path = wxString::FromUTF8Unchecked( KICAD_DOCS );
343#endif
344
345 return path;
346}

References path.

Referenced by SearchHelpFileFullPath().

◆ GetLocaleDataPath()

wxString PATHS::GetLocaleDataPath ( )
static

Gets the locales translation data path.

Definition at line 252 of file paths.cpp.

253{
254 wxString path;
255
256 path = GetStockDataPath() + wxT( "/internat" );
257
258 return path;
259}
static wxString GetStockDataPath(bool aRespectRunFromBuildDir=true)
Gets the stock (install) data path, which is the base path for things like scripting,...
Definition: paths.cpp:150

References GetStockDataPath(), and path.

Referenced by PGM_BASE::SetLanguagePath().

◆ GetStock3dmodelsPath()

wxString PATHS::GetStock3dmodelsPath ( )
static

Gets the stock (install) 3dmodels path.

Definition at line 222 of file paths.cpp.

223{
224 wxString path;
225
226 path = GetStockEDALibraryPath() + wxT( "/3dmodels" );
227
228 return path;
229}
static wxString GetStockEDALibraryPath()
Gets the stock (install) EDA library data path, which is the base path for templates,...
Definition: paths.cpp:186

References GetStockEDALibraryPath(), and path.

◆ GetStockDataPath()

wxString PATHS::GetStockDataPath ( bool  aRespectRunFromBuildDir = true)
static

Gets the stock (install) data path, which is the base path for things like scripting, etc.

Definition at line 150 of file paths.cpp.

151{
152 wxString path;
153
154 if( aRespectRunFromBuildDir && wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
155 {
156 // Allow debugging from build dir by placing relevant files/folders in the build root
157#if defined( __WXMAC__ )
158 wxFileName fn = wxStandardPaths::Get().GetExecutablePath();
159
160 fn.RemoveLastDir();
161 fn.RemoveLastDir();
162 fn.RemoveLastDir();
163 fn.RemoveLastDir();
164 path = fn.GetPath();
165#elif defined( __WXMSW__ )
166 path = getWindowsKiCadRoot();
167#else
168 path = Pgm().GetExecutablePath() + wxT( ".." );
169#endif
170 }
171 else
172 {
173#if defined( __WXMAC__ )
174 path = GetOSXKicadDataDir();
175#elif defined( __WXMSW__ )
176 path = getWindowsKiCadRoot() + wxT( "share/kicad" );
177#else
178 path = wxString::FromUTF8Unchecked( KICAD_DATA );
179#endif
180 }
181
182 return path;
183}
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References path, and Pgm().

Referenced by BITMAP_STORE::BITMAP_STORE(), GetBitmapStore(), GetLocaleDataPath(), GetStockDemosPath(), GetStockEDALibraryPath(), GetStockPluginsPath(), GetStockScriptingPath(), and PLUGIN_CONTENT_MANAGER::PLUGIN_CONTENT_MANAGER().

◆ GetStockDemosPath()

wxString PATHS::GetStockDemosPath ( )
static

Gets the stock (install) demos path.

Definition at line 310 of file paths.cpp.

311{
312 wxFileName fn;
313
314 fn.AssignDir( PATHS::GetStockDataPath( false ) );
315 fn.AppendDir( wxT( "demos" ) );
316
317 return fn.GetPathWithSep();
318}

References GetStockDataPath().

Referenced by KICAD_MANAGER_CONTROL::OpenDemoProject(), and KICAD_MANAGER_FRAME::ReCreateMenuBar().

◆ GetStockEDALibraryPath()

wxString PATHS::GetStockEDALibraryPath ( )
static

Gets the stock (install) EDA library data path, which is the base path for templates, schematic symbols, footprints, and 3D models.

Definition at line 186 of file paths.cpp.

187{
188 wxString path;
189
190#if defined( __WXMAC__ )
191 path = GetOSXKicadMachineDataDir();
192#elif defined( __WXMSW__ )
193 path = GetStockDataPath( false );
194#else
195 path = wxString::FromUTF8Unchecked( KICAD_LIBRARY_DATA );
196#endif
197
198 return path;
199}

References GetStockDataPath(), and path.

Referenced by GetStock3dmodelsPath(), GetStockFootprintsPath(), GetStockSymbolsPath(), GetStockTemplatesPath(), COMMON_SETTINGS::InitializeEnvironment(), and SystemDirsAppend().

◆ GetStockFootprintsPath()

wxString PATHS::GetStockFootprintsPath ( )
static

Gets the stock (install) footprints path.

Definition at line 212 of file paths.cpp.

213{
214 wxString path;
215
216 path = GetStockEDALibraryPath() + wxT( "/footprints" );
217
218 return path;
219}

References GetStockEDALibraryPath(), and path.

◆ GetStockPlugins3DPath()

wxString PATHS::GetStockPlugins3DPath ( )
static

Gets the stock (install) 3d viewer plugins path.

Definition at line 278 of file paths.cpp.

279{
280 wxFileName fn;
281
282#ifdef __WXGTK__
283 // KICAD_PLUGINDIR = CMAKE_INSTALL_FULL_LIBDIR path is the absolute path
284 // corresponding to the install path used for constructing KICAD_USER_PLUGIN
285 wxString tfname = wxString::FromUTF8Unchecked( KICAD_PLUGINDIR );
286 fn.Assign( tfname, "" );
287 fn.AppendDir( wxT( "kicad" ) );
288 fn.AppendDir( wxT( "plugins" ) );
289#elif defined( __WXMAC__ )
290 fn.Assign( wxStandardPaths::Get().GetPluginsDir(), wxEmptyString );
291#else
292 if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
293 {
294 fn.AssignDir( getWindowsKiCadRoot() );
295 }
296 else
297 {
298 fn.AssignDir( Pgm().GetExecutablePath() );
299 }
300
301 fn.AppendDir( wxT( "plugins" ) );
302#endif
303
304 fn.AppendDir( wxT( "3d" ) );
305
306 return fn.GetPathWithSep();
307}

References Pgm().

Referenced by S3D_PLUGIN_MANAGER::loadPlugins().

◆ GetStockPluginsPath()

wxString PATHS::GetStockPluginsPath ( )
static

Gets the stock (install) plugins path.

Definition at line 262 of file paths.cpp.

263{
264 wxFileName fn;
265
266#if defined( __WXMSW__ )
267 fn.AssignDir( Pgm().GetExecutablePath() );
268 fn.AppendDir( wxT( "scripting" ) );
269#else
270 fn.AssignDir( PATHS::GetStockDataPath( false ) );
271#endif
272 fn.AppendDir( wxT( "plugins" ) );
273
274 return fn.GetPathWithSep();
275}

References GetStockDataPath(), and Pgm().

Referenced by BOM_GENERATOR_HANDLER::FindFilePath(), and DIALOG_BOM::pluginInit().

◆ GetStockScriptingPath()

wxString PATHS::GetStockScriptingPath ( )
static

Gets the stock (install) scripting path.

Definition at line 232 of file paths.cpp.

233{
234 wxString path;
235
236 path = GetStockDataPath() + wxT( "/scripting" );
237
238 return path;
239}

References GetStockDataPath(), and path.

◆ GetStockSymbolsPath()

wxString PATHS::GetStockSymbolsPath ( )
static

Gets the stock (install) symbols path.

Definition at line 202 of file paths.cpp.

203{
204 wxString path;
205
206 path = GetStockEDALibraryPath() + wxT( "/symbols" );
207
208 return path;
209}

References GetStockEDALibraryPath(), and path.

◆ GetStockTemplatesPath()

wxString PATHS::GetStockTemplatesPath ( )
static

Gets the stock (install) templates path.

Definition at line 242 of file paths.cpp.

243{
244 wxString path;
245
246 path = GetStockEDALibraryPath() + wxT( "/template" );
247
248 return path;
249}

References GetStockEDALibraryPath(), and path.

Referenced by COMMON_SETTINGS::InitializeEnvironment().

◆ GetUserCachePath()

wxString PATHS::GetUserCachePath ( )
static

Gets the stock (install) 3d viewer plugins path.

Definition at line 321 of file paths.cpp.

322{
323 wxFileName tmp;
324
325 tmp.AssignDir( KIPLATFORM::ENV::GetUserCachePath() );
326 tmp.AppendDir( KICAD_PATH_STR );
327 tmp.AppendDir( SETTINGS_MANAGER::GetSettingsVersion() );
328
329 return tmp.GetPathWithSep();
330}
static std::string GetSettingsVersion()
Parses the current KiCad build version and extracts the major and minor revision to use as the name o...
wxString GetUserCachePath()
Retrieves the operating system specific path for user's application cache.
#define KICAD_PATH_STR
Definition: paths.cpp:35

References SETTINGS_MANAGER::GetSettingsVersion(), KIPLATFORM::ENV::GetUserCachePath(), and KICAD_PATH_STR.

Referenced by PLUGIN_CONTENT_MANAGER::CacheRepository(), PLUGIN_CONTENT_MANAGER::DiscardRepositoryCache(), PCM_TASK_MANAGER::DownloadAndInstall(), EnsureUserPathsExist(), PLUGIN_CONTENT_MANAGER::GetRepositoryPackageBitmaps(), NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries(), and S3D_CACHE::Set3DConfigDir().

◆ getUserDocumentPath()

void PATHS::getUserDocumentPath ( wxFileName &  aPath)
staticprivate

Gets the user path for the current kicad version which acts as the root for other user paths.

Parameters
aPathVariable to receive the path

Definition at line 39 of file paths.cpp.

40{
41 wxString envPath;
42
43 if( wxGetEnv( wxT( "KICAD_DOCUMENTS_HOME" ), &envPath ) )
44 aPath.AssignDir( envPath );
45 else
46 aPath.AssignDir( KIPLATFORM::ENV::GetDocumentsPath() );
47
48 aPath.AppendDir( KICAD_PATH_STR );
49 aPath.AppendDir( SETTINGS_MANAGER::GetSettingsVersion() );
50}
wxString GetDocumentsPath()
Retrieves the operating system specific path for a user's documents.

References KIPLATFORM::ENV::GetDocumentsPath(), SETTINGS_MANAGER::GetSettingsVersion(), and KICAD_PATH_STR.

Referenced by GetDefault3rdPartyPath(), GetDefaultUser3DModelsPath(), GetDefaultUserFootprintsPath(), GetDefaultUserProjectsPath(), GetDefaultUserSymbolsPath(), GetUserPluginsPath(), GetUserScriptingPath(), and GetUserTemplatesPath().

◆ GetUserPlugins3DPath()

wxString PATHS::GetUserPlugins3DPath ( )
static

Gets the user path for 3d viewer plugin.

Definition at line 64 of file paths.cpp.

65{
66 wxFileName tmp;
67
68 tmp.AssignDir( PATHS::GetUserPluginsPath() );
69 tmp.AppendDir( wxT( "3d" ) );
70
71 return tmp.GetPath();
72}

References GetUserPluginsPath().

Referenced by EnsureUserPathsExist().

◆ GetUserPluginsPath()

wxString PATHS::GetUserPluginsPath ( )
static

Gets the user path for plugins.

Definition at line 53 of file paths.cpp.

54{
55 wxFileName tmp;
57
58 tmp.AppendDir( wxT( "plugins" ) );
59
60 return tmp.GetPath();
61}

References getUserDocumentPath().

Referenced by DIALOG_BOM::chooseGenerator(), EnsureUserPathsExist(), BOM_GENERATOR_HANDLER::FindFilePath(), GetUserPlugins3DPath(), and DIALOG_BOM::pluginInit().

◆ GetUserScriptingPath()

wxString PATHS::GetUserScriptingPath ( )
static

Gets the user path for python scripts.

Definition at line 75 of file paths.cpp.

76{
77 wxFileName tmp;
79
80 tmp.AppendDir( wxT( "scripting" ) );
81
82 return tmp.GetPath();
83}

References getUserDocumentPath().

Referenced by EnsureUserPathsExist().

◆ GetUserTemplatesPath()

wxString PATHS::GetUserTemplatesPath ( )
static

Gets the user path for custom templates.

Definition at line 86 of file paths.cpp.

87{
88 wxFileName tmp;
90
91 tmp.AppendDir( wxT( "template" ) );
92
93 return tmp.GetPathWithSep();
94}

References getUserDocumentPath().

Referenced by EnsureUserPathsExist(), PL_EDITOR_FRAME::Files_io(), COMMON_SETTINGS::InitializeEnvironment(), and PGM_KICAD::OnPgmInit().


The documentation for this class was generated from the following files: