You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
4.8 KiB

4 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef PATHS_H
  20. #define PATHS_H
  21. #include <wx/filename.h>
  22. #include <wx/string.h>
  23. /**
  24. * Helper class to centralize the paths used throughout kicad
  25. */
  26. class PATHS
  27. {
  28. public:
  29. /**
  30. * Gets the user path for python scripts
  31. */
  32. static wxString GetUserScriptingPath();
  33. /**
  34. * Gets the user path for custom templates
  35. */
  36. static wxString GetUserTemplatesPath();
  37. /**
  38. * Gets the user path for plugins
  39. */
  40. static wxString GetUserPluginsPath();
  41. /**
  42. * Gets the user path for 3d viewer plugin
  43. */
  44. static wxString GetUserPlugins3DPath();
  45. /**
  46. * Gets the default path we point users to create projects
  47. */
  48. static wxString GetDefaultUserProjectsPath();
  49. /**
  50. * Gets the default path we point users to create projects
  51. */
  52. static wxString GetDefaultUserSymbolsPath();
  53. /**
  54. * Gets the default path we point users to create projects
  55. */
  56. static wxString GetDefaultUserFootprintsPath();
  57. /**
  58. * Gets the default path we point users to create projects
  59. */
  60. static wxString GetDefaultUser3DModelsPath();
  61. /**
  62. * Gets the stock (install) data path, which is the base path for things like scripting, etc
  63. */
  64. static wxString GetStockDataPath( bool aRespectRunFromBuildDir = true );
  65. /**
  66. * Gets the stock (install) EDA library data path, which is the base path for
  67. * templates, schematic symbols, footprints, and 3D models.
  68. */
  69. static wxString GetStockEDALibraryPath();
  70. /**
  71. * Gets the default path for PCM packages
  72. */
  73. static wxString GetDefault3rdPartyPath();
  74. /**
  75. * Gets the stock (install) symbols path
  76. */
  77. static wxString GetStockSymbolsPath();
  78. /**
  79. * Gets the stock (install) footprints path
  80. */
  81. static wxString GetStockFootprintsPath();
  82. /**
  83. * Gets the stock (install) 3dmodels path
  84. */
  85. static wxString GetStock3dmodelsPath();
  86. /**
  87. * Gets the stock (install) scripting path
  88. */
  89. static wxString GetStockScriptingPath();
  90. /**
  91. * Gets the stock (install) plugins path
  92. */
  93. static wxString GetStockPluginsPath();
  94. /**
  95. * Gets the stock (install) 3d viewer plugins path
  96. */
  97. static wxString GetStockPlugins3DPath();
  98. /**
  99. * Gets the stock (install) demos path
  100. */
  101. static wxString GetStockDemosPath();
  102. /**
  103. * Gets the stock (install) templates path
  104. */
  105. static wxString GetStockTemplatesPath();
  106. /**
  107. * Gets the locales translation data path
  108. */
  109. static wxString GetLocaleDataPath();
  110. /**
  111. * Gets the stock (install) 3d viewer plugins path
  112. */
  113. static wxString GetUserCachePath();
  114. /**
  115. * Gets the documentation path, which is the base path for help files
  116. */
  117. static wxString GetDocumentationPath();
  118. /**
  119. * Attempts to create a given path if it does not exist
  120. */
  121. static bool EnsurePathExists( const wxString& aPath );
  122. /**
  123. * Ensures/creates user default paths
  124. */
  125. static void EnsureUserPathsExist();
  126. #ifdef __WXMAC__
  127. /**
  128. * OSX specific function GetOSXKicadUserDataDir
  129. *
  130. * @return The macOS specific user data directory for KiCad.
  131. */
  132. static wxString GetOSXKicadUserDataDir();
  133. /**
  134. * @return The macOS specific machine data directory for KiCad
  135. */
  136. static wxString GetOSXKicadMachineDataDir();
  137. /**
  138. * @return The macOS specific bundle data directory for KiCad
  139. */
  140. static wxString GetOSXKicadDataDir();
  141. #endif
  142. private:
  143. // we are a static helper
  144. PATHS() {}
  145. /**
  146. * Gets the user path for the current kicad version which acts as the root for other user paths
  147. *
  148. * @param aPath Variable to receive the path
  149. */
  150. static void getUserDocumentPath( wxFileName& aPath );
  151. #ifdef __WXWINDOWS__
  152. /**
  153. * Gets the root of the kicad install on Windows specifically.
  154. * KiCad on Windows has a pseudo posix folder structure contained in its installed folder
  155. * This retrieves that root for usage in other methods
  156. */
  157. static wxString getWindowsKiCadRoot();
  158. #endif
  159. };
  160. #endif