20 #include <wx/filename.h> 21 #include <wx/stdpaths.h> 22 #include <wx/string.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, wxEmptyString );
287 fn.AppendDir( wxT(
"kicad" ) );
288 fn.AppendDir( wxT(
"plugins" ) );
289 #elif defined( __WXMAC__ ) 290 fn.Assign( wxStandardPaths::Get().GetPluginsDir(), wxEmptyString );
292 fn.AssignDir(
Pgm().GetExecutablePath() );
293 fn.AppendDir( wxT(
"plugins" ) );
296 fn.AppendDir( wxT(
"3d" ) );
298 return fn.GetPathWithSep();
307 fn.AppendDir( wxT(
"demos" ) );
309 return fn.GetPathWithSep();
321 return tmp.GetPathWithSep();
329 #if defined( __WXMAC__ ) 330 path = GetOSXKicadDataDir();
331 #elif defined( __WXMSW__ ) 332 path = getWindowsKiCadRoot() + wxT(
"share/doc/kicad" );
334 path = wxString::FromUTF8Unchecked( KICAD_DOCS );
343 wxFileName
path( aPath );
344 if( !
path.Normalize() )
349 if( !wxFileName::DirExists( aPath ) )
351 if( !wxFileName::Mkdir( aPath, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
376 wxString PATHS::GetOSXKicadUserDataDir()
380 wxFileName udir( wxStandardPaths::Get().GetUserDataDir(), wxEmptyString );
384 udir.RemoveLastDir();
385 udir.AppendDir( wxT(
"kicad" ) );
387 return udir.GetPath();
391 wxString PATHS::GetOSXKicadMachineDataDir()
394 return GetOSXKicadDataDir();
398 wxString PATHS::GetOSXKicadDataDir()
402 wxFileName ddir( wxStandardPaths::Get().GetDataDir(), wxEmptyString );
405 const wxArrayString dirs = ddir.GetDirs();
411 if( dirs.GetCount() >= 6 &&
412 dirs[dirs.GetCount() - 4] == wxT(
"Applications" ) &&
413 dirs[dirs.GetCount() - 6].Lower().EndsWith( wxT(
"app" ) ) )
415 ddir.RemoveLastDir();
416 ddir.RemoveLastDir();
417 ddir.RemoveLastDir();
418 ddir.RemoveLastDir();
419 ddir.AppendDir( wxT(
"SharedSupport" ) );
422 return ddir.GetPath();
428 wxString PATHS::getWindowsKiCadRoot()
430 wxFileName root(
Pgm().GetExecutablePath() + wxT(
"/../" ) );
433 return root.GetPathWithSep();
static bool EnsurePathExists(const wxString &aPath)
Attempts to create a given path if it does not exist.
static wxString GetDefaultUser3DModelsPath()
Gets the default path we point users to create projects.
static wxString GetUserScriptingPath()
Gets the user path for python scripts.
static wxString GetStockScriptingPath()
Gets the stock (install) scripting path.
static wxString GetStockPlugins3DPath()
Gets the stock (install) 3d viewer plugins path.
static wxString GetStockSymbolsPath()
Gets the stock (install) symbols path.
static wxString GetUserCachePath()
Gets the stock (install) 3d viewer plugins path.
static void getUserDocumentPath(wxFileName &aPath)
Gets the user path for the current kicad version which acts as the root for other user paths.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
static wxString GetDocumentationPath()
Gets the documentation path, which is the base path for help files.
static wxString GetStockDataPath(bool aRespectRunFromBuildDir=true)
Gets the stock (install) data path, which is the base path for things like scripting,...
static wxString GetStockTemplatesPath()
Gets the stock (install) templates path.
static wxString GetUserPlugins3DPath()
Gets the user path for 3d viewer plugin.
static wxString GetUserPluginsPath()
Gets the user path for plugins.
static wxString GetUserTemplatesPath()
Gets the user path for custom templates.
static void EnsureUserPathsExist()
Ensures/creates user default paths.
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
static wxString GetDefaultUserFootprintsPath()
Gets the default path we point users to create projects.
static wxString GetStockFootprintsPath()
Gets the stock (install) footprints path.
static wxString GetStockDemosPath()
Gets the stock (install) demos path.
static wxString GetStockEDALibraryPath()
Gets the stock (install) EDA library data path, which is the base path for templates,...
static wxString GetStock3dmodelsPath()
Gets the stock (install) 3dmodels path.
static std::string GetSettingsVersion()
Parses the current KiCad build version and extracts the major and minor revision to use as the name o...
static wxString GetDefault3rdPartyPath()
Gets the default path for PCM packages.
static wxString GetLocaleDataPath()
Gets the locales translation data path.
static wxString GetStockPluginsPath()
Gets the stock (install) plugins path.