Open a document (file) with the suitable browser.
Environmental variables are substituted before the document name is resolved for either browser or file. If aDocName begins with http: or ftp: or www. the default internet browser is launched.
83 wxString fullfilename;
89 SEARCH_STACK* aPaths = aProject ? aProject->SchSearchS() :
nullptr;
93 static const std::vector<wxString> url_header =
105 for(
const wxString& proc : url_header)
107 if( docname.StartsWith( proc ) )
109 wxURI uri( docname );
110 wxLaunchDefaultBrowser( uri.BuildURI() );
123 if( wxIsAbsolutePath( docname ) || aPaths ==
NULL )
124 fullfilename = docname;
129 else if( wxFileName::FileExists( docname ) )
130 fullfilename = docname;
134 wxString mask( wxT(
"*" ) ), extension;
138 extension = wxT(
".*" );
141 if( wxIsWild( fullfilename ) )
144 wxPathOnly( fullfilename ),
152 if( fullfilename.IsEmpty() )
156 if( !wxFileExists( fullfilename ) )
158 msg.Printf(
_(
"Doc File \"%s\" not found" ), docname );
163 wxFileName currentFileName( fullfilename );
165 wxString file_ext = currentFileName.GetExt();
167 if( file_ext.Lower() == wxT(
"pdf" ) )
169 success =
OpenPDF( fullfilename );
174 wxFileType* filetype;
177 filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );
183 filetype =
mimeDatabase->GetFileTypeFromExtension( file_ext );
190 wxFileType::MessageParameters params( fullfilename, type );
192 success = filetype->GetOpenCommand( &command, params );
201 msg.Printf(
_(
"Unknown MIME type for doc file \"%s\"" ), fullfilename );
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
wxString FindValidPath(const wxString &aFileName) const
int ProcessExecute(const wxString &aCommandLine, int aFlags, wxProcess *callback)
Run a command in a child process.
#define WIN_STRING_DIR_SEP
#define UNIX_STRING_DIR_SEP
Look for files in a number of paths.
static wxMimeTypesManager * mimeDatabase
static const wxFileTypeInfo EDAfallbacks[]
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
A helper function that wraps a call to wxFileSelector.
const wxString ResolveUriByEnvVars(const wxString &aUri, PROJECT *aProject)
Replace any environment and/or text variables in file-path uris (leaving network-path URIs alone).
bool OpenPDF(const wxString &file)
Run the PDF viewer and display a PDF file.