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 return tmp.GetPathWithSep();
337#if defined( __WXMAC__ )
338 path = GetOSXKicadDataDir();
339#elif defined( __WXMSW__ )
340 path = getWindowsKiCadRoot() + wxT(
"share/doc/kicad" );
342 path = wxString::FromUTF8Unchecked( KICAD_DOCS );
351 wxFileName
path( aPath );
352 if( !
path.MakeAbsolute() )
357 if( !wxFileName::DirExists( aPath ) )
359 if( !wxFileName::Mkdir( aPath, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
385wxString PATHS::GetOSXKicadUserDataDir()
389 wxFileName udir( wxStandardPaths::Get().GetUserDataDir(), wxEmptyString );
393 udir.RemoveLastDir();
394 udir.AppendDir( wxT(
"kicad" ) );
396 return udir.GetPath();
400wxString PATHS::GetOSXKicadMachineDataDir()
403 return GetOSXKicadDataDir();
407wxString PATHS::GetOSXKicadDataDir()
411 wxFileName ddir( wxStandardPaths::Get().GetDataDir(), wxEmptyString );
414 const wxArrayString dirs = ddir.GetDirs();
420 if( dirs.GetCount() >= 6 &&
421 dirs[dirs.GetCount() - 4] == wxT(
"Applications" ) &&
422 dirs[dirs.GetCount() - 6].Lower().EndsWith( wxT(
"app" ) ) )
424 ddir.RemoveLastDir();
425 ddir.RemoveLastDir();
426 ddir.RemoveLastDir();
427 ddir.RemoveLastDir();
428 ddir.AppendDir( wxT(
"SharedSupport" ) );
431 return ddir.GetPath();
437wxString PATHS::getWindowsKiCadRoot()
439 wxFileName root(
Pgm().GetExecutablePath() + wxT(
"/../" ) );
442 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.