Return the help file's full path.
Return the full path and name (including extension) of the given KiCad help file. It is expected to be found in a subfolder help/<LANG>/ in one of the system paths. Supported file types are *.html and *.pdf. If no such file is available for the current locale, an attempt to find the English version is made. The search order for <LANG> is: 1) canonical form (e.g., "fr_FR"), 2) short form (e.g., "fr"), and 3) "en".
33{
35 wxString helpFile;
36
37
39
40#ifndef __WIN32__
41
43#endif
44
45#if defined( DEBUG )
46 basePaths.Show( wxString( __func__ ) + wxS( ": basePaths" ) );
47#endif
48
49
50
51
52
53
54
55 wxLocale* currentLocale =
Pgm().GetLocale();
56 wxArrayString localeNameDirs;
57
58
59 localeNameDirs.Add( currentLocale->GetCanonicalName() );
60
61
62
63 localeNameDirs.Add( currentLocale->GetName().BeforeLast( wxS( '_' ) ) );
64
65
66 localeNameDirs.Add( wxS( "en" ) );
67
68 for( wxString& locale : localeNameDirs )
69 {
71
72 for( wxString& base : basePaths )
73 {
74 wxFileName
path( base, wxEmptyString );
75
76
77 path.AppendDir( wxS(
"help" ) );
78 path.AppendDir( locale );
80
81
82 path.InsertDir(
path.GetDirCount() - 2, wxS(
"doc" ) );
84
85
86 path.InsertDir(
path.GetDirCount() - 2, wxS(
"kicad" ) );
88 }
89
90#if defined( DEBUG )
91 docPaths.Show( wxString( __func__ ) + wxS( ": docPaths (" ) + locale + wxS( ")" ) );
92#endif
93
94
96 aBaseName );
97 helpFile = docPaths.FindValidPath( aBaseName + wxS( ".html" ) );
98
99 if( !helpFile.IsEmpty() )
100 {
101
102 helpFile = wxS( "file://" ) + helpFile;
103 break;
104 }
105
106
107 wxLogTrace(
tracePathsAndFiles, wxS(
"Checking SEARCH_STACK for file %s.pdf" ), aBaseName );
108 helpFile = docPaths.FindValidPath( aBaseName + wxS( ".pdf" ) );
109
110 if( !helpFile.IsEmpty() )
111 break;
112 }
113
114 return helpFile;
115}
static wxString GetDocumentationPath()
Gets the documentation path, which is the base path for help files.
Look for files in a number of paths.
void AddPaths(const wxString &aPaths, int aIndex=-1)
Insert or append path(s).
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Append system places to aSearchStack in a platform specific way and pertinent to KiCad programs.