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 "KiCad" 35 #define KICAD_PATH_STR "kicad" 43 if( wxGetEnv( wxT(
"KICAD_DOCUMENTS_HOME" ), &envPath ) )
44 aPath.AssignDir( envPath );
58 tmp.AppendDir(
"plugins" );
69 tmp.AppendDir(
"3d" );
80 tmp.AppendDir(
"scripting" );
91 tmp.AppendDir(
"template" );
93 return tmp.GetPathWithSep();
102 tmp.AppendDir(
"symbols" );
104 return tmp.GetPath();
113 tmp.AppendDir(
"footprints" );
115 return tmp.GetPath();
124 tmp.AppendDir(
"3dmodels" );
126 return tmp.GetPath();
135 tmp.AppendDir(
"projects" );
137 return tmp.GetPath();
145 if( aRespectRunFromBuildDir && wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
148 path =
Pgm().GetExecutablePath() + wxT(
".." );
152 #if defined( __WXMAC__ ) 153 path = GetOSXKicadDataDir();
154 #elif defined( __WXMSW__ ) 155 path =
Pgm().GetExecutablePath() + wxT(
"../share/kicad" );
157 path = wxString::FromUTF8Unchecked( KICAD_DATA );
169 #if defined( __WXMAC__ ) 170 path = GetOSXKicadMachineDataDir();
171 #elif defined( __WXMSW__ ) 174 path = wxString::FromUTF8Unchecked( KICAD_LIBRARY_DATA );
195 #if defined( __WXMSW__ ) 196 fn.AssignDir(
Pgm().GetExecutablePath() );
197 fn.AppendDir( wxT(
"scripting" ) );
201 fn.AppendDir( wxT(
"plugins" ) );
203 return fn.GetPathWithSep();
214 wxString tfname = wxString::FromUTF8Unchecked( KICAD_PLUGINDIR );
215 fn.Assign( tfname,
"" );
216 fn.AppendDir( wxT(
"kicad" ) );
217 fn.AppendDir( wxT(
"plugins" ) );
218 #elif defined( __WXMAC__ ) 219 fn.Assign( wxStandardPaths::Get().GetPluginsDir(), wxEmptyString );
221 fn.AssignDir(
Pgm().GetExecutablePath() );
222 fn.AppendDir( wxT(
"plugins" ) );
225 fn.AppendDir(
"3d" );
227 return fn.GetPathWithSep();
239 return tmp.GetPathWithSep();
247 #if defined( __WXMAC__ ) 248 path = GetOSXKicadDataDir();
249 #elif defined( __WXMSW__ ) 250 path =
Pgm().GetExecutablePath() +
"../share/doc/kicad";
252 path = wxString::FromUTF8Unchecked( KICAD_DOCS );
261 wxFileName
path( aPath );
262 if( !
path.Normalize() )
267 if( !wxFileName::DirExists( aPath ) )
269 if( !wxFileName::Mkdir( aPath, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
293 wxString PATHS::GetOSXKicadUserDataDir()
297 wxFileName udir( wxStandardPaths::Get().GetUserDataDir(), wxEmptyString );
301 udir.RemoveLastDir();
302 udir.AppendDir(
"kicad" );
304 return udir.GetPath();
308 wxString PATHS::GetOSXKicadMachineDataDir()
310 return wxT(
"/Library/Application Support/kicad" );
314 wxString PATHS::GetOSXKicadDataDir()
318 wxFileName ddir( wxStandardPaths::Get().GetDataDir(), wxEmptyString );
321 const wxArrayString dirs = ddir.GetDirs();
322 if( dirs[dirs.GetCount() - 3].Lower() != wxT(
"kicad.app" ) )
328 ddir.RemoveLastDir();
329 ddir.RemoveLastDir();
330 ddir.RemoveLastDir();
331 ddir.RemoveLastDir();
332 ddir.AppendDir( wxT(
"SharedSupport" ) );
335 return ddir.GetPath();
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 pluginspath.
static wxString GetUserCachePath()
Gets the stock (install) 3d viewer pluginspath.
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 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 GetStockEDALibraryPath()
Gets the stock (install) EDA library data path, which is the base path for templates,...
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 GetStockPluginsPath()
Gets the stock (install) plugins path.