+// ----------------------------------------------------------------------------
+// Launch document with default app
+// ----------------------------------------------------------------------------
+
+bool wxLaunchDefaultApplication(const wxString& document, int flags)
+{
+ wxUnusedVar(flags);
+
+#ifdef __WXMAC__
+ static const char * const OPEN_CMD = "/usr/bin/open";
+ if ( wxFileExists(OPEN_CMD) &&
+ wxExecute(wxString(OPEN_CMD) + " " + document) )
+ return true;
+#elif defined(__UNIX__)
+ // Our best best is to use xdg-open from freedesktop.org cross-desktop
+ // compatibility suite xdg-utils
+ // (see http://portland.freedesktop.org/wiki/) -- this is installed on
+ // most modern distributions and may be tweaked by them to handle
+ // distribution specifics.
+ wxString path, xdg_open;
+ if ( wxGetEnv("PATH", &path) &&
+ wxFindFileInPath(&xdg_open, path, "xdg-open") )
+ {
+ if ( wxExecute(xdg_open + " " + document) )
+ return true;
+ }
+#elif defined(__WXMSW__)
+ WinStruct<SHELLEXECUTEINFO> sei;
+ sei.lpFile = document.wx_str();
+ sei.lpVerb = _T("open");
+ sei.nShow = SW_SHOWDEFAULT;
+
+ // avoid Windows message box in case of error for consistency with
+ // wxLaunchDefaultBrowser() even if don't show the error ourselves in this
+ // function
+ sei.fMask = SEE_MASK_FLAG_NO_UI;
+
+ if ( ::ShellExecuteEx(&sei) )
+ return true;
+#endif
+
+ return false;
+}
+