diff --git a/common/paths.cpp b/common/paths.cpp index 69e4ec4611..9f3aa7aeb9 100644 --- a/common/paths.cpp +++ b/common/paths.cpp @@ -154,7 +154,7 @@ wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir ) fn.RemoveLastDir(); path = fn.GetPath(); #else - path = Pgm().GetExecutablePath() + wxT( ".." ); + path = getWindowsKiCadRoot(); #endif } else @@ -162,7 +162,7 @@ wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir ) #if defined( __WXMAC__ ) path = GetOSXKicadDataDir(); #elif defined( __WXMSW__ ) - path = Pgm().GetExecutablePath() + wxT( "../share/kicad" ); + path = getWindowsKiCadRoot() + wxT( "share/kicad" ); #else path = wxString::FromUTF8Unchecked( KICAD_DATA ); #endif @@ -257,7 +257,7 @@ wxString PATHS::GetDocumentationPath() #if defined( __WXMAC__ ) path = GetOSXKicadDataDir(); #elif defined( __WXMSW__ ) - path = Pgm().GetExecutablePath() + "../share/doc/kicad"; + path = getWindowsKiCadRoot() + "share/doc/kicad"; #else path = wxString::FromUTF8Unchecked( KICAD_DOCS ); #endif @@ -345,3 +345,14 @@ wxString PATHS::GetOSXKicadDataDir() return ddir.GetPath(); } #endif + + +#ifdef __WXWINDOWS__ +wxString PATHS::getWindowsKiCadRoot() +{ + wxFileName root(Pgm().GetExecutablePath() + "/../"); + root.MakeAbsolute(); + + return root.GetPathWithSep(); +} +#endif diff --git a/include/paths.h b/include/paths.h index 0b1560ff7e..8f67d17318 100644 --- a/include/paths.h +++ b/include/paths.h @@ -145,6 +145,15 @@ private: * @param aPath Variable to receive the path */ static void getUserDocumentPath( wxFileName& aPath ); + +#ifdef __WXWINDOWS__ + /** + * Gets the root of the kicad install on Windows specifically. + * KiCad on Windows has a psuedo posix folder structure contained in it's installed folder + * This retrieves that root for usage in other methods + */ + static wxString getWindowsKiCadRoot(); +#endif }; #endif