20#include <wx/filename.h>
21#include <wx/stdpaths.h>
32#if defined( __WXMAC__ ) || defined( __WXMSW__ )
33#define KICAD_PATH_STR wxT( "KiCad" )
35#define KICAD_PATH_STR wxT( "kicad" )
43 if( wxGetEnv( wxT(
"KICAD_DOCUMENTS_HOME" ), &envPath ) )
44 aPath.AssignDir( envPath );
58 tmp.AppendDir( wxT(
"plugins" ) );
69 tmp.AppendDir( wxT(
"3d" ) );
80 tmp.AppendDir( wxT(
"scripting" ) );
91 tmp.AppendDir( wxT(
"template" ) );
93 return tmp.GetPathWithSep();
102 tmp.AppendDir( wxT(
"symbols" ) );
104 return tmp.GetPath();
113 tmp.AppendDir( wxT(
"footprints" ) );
115 return tmp.GetPath();
124 tmp.AppendDir( wxT(
"3dmodels" ) );
126 return tmp.GetPath();
134 tmp.AppendDir( wxT(
"3rdparty" ) );
136 return tmp.GetPath();
144 tmp.AppendDir( wxT(
"projects" ) );
146 return tmp.GetPath();
154 if( aRespectRunFromBuildDir && wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
157#if defined( __WXMAC__ )
158 wxFileName fn = wxStandardPaths::Get().GetExecutablePath();
165#elif defined( __WXMSW__ )
166 path = getWindowsKiCadRoot();
168 path =
Pgm().GetExecutablePath() + wxT(
".." );
173#if defined( __WXMAC__ )
174 path = GetOSXKicadDataDir();
175#elif defined( __WXMSW__ )
176 path = getWindowsKiCadRoot() + wxT(
"share/kicad" );
178 path = wxString::FromUTF8Unchecked( KICAD_DATA );
190#if defined( __WXMAC__ )
191 path = GetOSXKicadMachineDataDir();
192#elif defined( __WXMSW__ )
195 path = wxString::FromUTF8Unchecked( KICAD_LIBRARY_DATA );
266#if defined( __WXMSW__ )
267 fn.AssignDir(
Pgm().GetExecutablePath() );
268 fn.AppendDir( wxT(
"scripting" ) );
272 fn.AppendDir( wxT(
"plugins" ) );
274 return fn.GetPathWithSep();
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 );
292 if( wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
294 fn.AssignDir( getWindowsKiCadRoot() );
298 fn.AssignDir(
Pgm().GetExecutablePath() );
301 fn.AppendDir( wxT(
"plugins" ) );
304 fn.AppendDir( wxT(
"3d" ) );
306 return fn.GetPathWithSep();
315 fn.AppendDir( wxT(
"demos" ) );
317 return fn.GetPathWithSep();
329 if( wxGetEnv( wxT(
"KICAD_CACHE_HOME" ), &envPath ) && !envPath.IsEmpty() )
332 tmp.AssignDir( envPath );
338 return tmp.GetPathWithSep();
346#if defined( __WXMAC__ )
347 path = GetOSXKicadDataDir();
348#elif defined( __WXMSW__ )
349 path = getWindowsKiCadRoot() + wxT(
"share/doc/kicad" );
351 path = wxString::FromUTF8Unchecked( KICAD_DOCS );
360 wxFileName
path( aPath );
361 if( !
path.MakeAbsolute() )
366 if( !wxFileName::DirExists( aPath ) )
368 if( !wxFileName::Mkdir( aPath, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
394wxString PATHS::GetOSXKicadUserDataDir()
398 wxFileName udir( wxStandardPaths::Get().GetUserDataDir(), wxEmptyString );
402 udir.RemoveLastDir();
403 udir.AppendDir( wxT(
"kicad" ) );
405 return udir.GetPath();
409wxString PATHS::GetOSXKicadMachineDataDir()
412 return GetOSXKicadDataDir();
416wxString PATHS::GetOSXKicadDataDir()
420 wxFileName ddir( wxStandardPaths::Get().GetDataDir(), wxEmptyString );
423 const wxArrayString dirs = ddir.GetDirs();
429 if( dirs.GetCount() >= 6 &&
430 dirs[dirs.GetCount() - 4] == wxT(
"Applications" ) &&
431 dirs[dirs.GetCount() - 6].Lower().EndsWith( wxT(
"app" ) ) )
433 ddir.RemoveLastDir();
434 ddir.RemoveLastDir();
435 ddir.RemoveLastDir();
436 ddir.RemoveLastDir();
437 ddir.AppendDir( wxT(
"SharedSupport" ) );
440 return ddir.GetPath();
446wxString PATHS::GetWindowsFontConfigDir()
449 fn.AssignDir( getWindowsKiCadRoot() );
450 fn.AppendDir( wxS(
"etc" ) );
451 fn.AppendDir( wxS(
"fonts" ) );
453 return fn.GetPathWithSep();
457wxString PATHS::getWindowsKiCadRoot()
459 wxFileName root(
Pgm().GetExecutablePath() + wxT(
"/../" ) );
462 return root.GetPathWithSep();
static wxString GetUserPluginsPath()
Gets the user path for plugins.
static wxString GetStockSymbolsPath()
Gets the stock (install) symbols path.
static wxString GetDefaultUser3DModelsPath()
Gets the default path we point users to create projects.
static wxString GetUserTemplatesPath()
Gets the user path for custom templates.
static void getUserDocumentPath(wxFileName &aPath)
Gets the user path for the current kicad version which acts as the root for other user paths.
static wxString GetStockEDALibraryPath()
Gets the stock (install) EDA library data path, which is the base path for templates,...
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
static wxString GetStockPluginsPath()
Gets the stock (install) plugins path.
static wxString GetUserPlugins3DPath()
Gets the user path for 3d viewer plugin.
static void EnsureUserPathsExist()
Ensures/creates user default paths.
static wxString GetDocumentationPath()
Gets the documentation path, which is the base path for help files.
static bool EnsurePathExists(const wxString &aPath)
Attempts to create a given path if it does not exist.
static wxString GetDefault3rdPartyPath()
Gets the default path for PCM packages.
static wxString GetStockPlugins3DPath()
Gets the stock (install) 3d viewer plugins path.
static wxString GetStockDataPath(bool aRespectRunFromBuildDir=true)
Gets the stock (install) data path, which is the base path for things like scripting,...
static wxString GetDefaultUserFootprintsPath()
Gets the default path we point users to create projects.
static wxString GetStock3dmodelsPath()
Gets the stock (install) 3dmodels path.
static wxString GetStockTemplatesPath()
Gets the stock (install) templates path.
static wxString GetUserCachePath()
Gets the stock (install) 3d viewer plugins path.
static wxString GetUserScriptingPath()
Gets the user path for python scripts.
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
static wxString GetStockDemosPath()
Gets the stock (install) demos path.
static wxString GetLocaleDataPath()
Gets the locales translation data path.
static wxString GetStockFootprintsPath()
Gets the stock (install) footprints path.
static wxString GetStockScriptingPath()
Gets the stock (install) scripting path.
static std::string GetSettingsVersion()
Parses the current KiCad build version and extracts the major and minor revision to use as the name o...
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.