bool GetMimeTypes(const wxString& uti, wxArrayString& mimeTypes);
bool GetIcon(const wxString& uti, wxIconLocation *iconLoc);
bool GetDescription(const wxString& uti, wxString *desc);
+ bool GetApplication(const wxString& uti, wxString *command);
// Structure to represent file types
typedef struct FileTypeData
wxArrayString extensions;
wxArrayString mimeTypes;
wxIconLocation iconLoc;
+ wxString application;
wxString description;
}
FileTypeInfo;
bool GetMimeTypes(wxArrayString& mimeTypes) const ;
bool GetIcon(wxIconLocation *iconLoc) const ;
bool GetDescription(wxString *desc) const ;
+ bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const;
// These functions are only stubs on Mac OS X
- bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const;
bool GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const;
size_t GetAllCommands(wxArrayString *verbs, wxArrayString *commands, const wxFileType::MessageParameters& params) const;
bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
if( !bundle )
return;
- // Get a all the document type data in this bundle
+ // Also get the open command while we have the bundle
+ wxCFStringRef cfsAppPath(CFURLCopyFileSystemPath(appUrl, kCFURLPOSIXPathStyle));
+ m_utiMap[ uti ].application = cfsAppPath.AsString();
+
+ // Get all the document type data in this bundle
CFTypeRef docTypeData;
docTypeData = CFBundleGetValueForInfoDictionaryKey( bundle, docTypesKey );
return true;
}
+bool wxMimeTypesManagerImpl::GetApplication(const wxString& uti, wxString *command)
+{
+ const UtiMap::const_iterator itr = m_utiMap.find( uti );
+
+ if( itr == m_utiMap.end() )
+ {
+ command->clear();
+ return false;
+ }
+
+ *command = itr->second.application;
+ return true;
+}
/////////////////////////////////////////////////////////////////////////////
// The remaining functionality has not yet been implemented for OS X
return m_manager->GetDescription( m_uti, desc );
}
-bool wxFileTypeImpl::GetOpenCommand(wxString *WXUNUSED(openCmd), const wxFileType::MessageParameters& WXUNUSED(params)) const
+namespace
{
- return false;
+
+// Helper function for GetOpenCommand(): returns the string surrounded by
+// (singly) quotes if it contains spaces.
+wxString QuoteIfNecessary(const wxString& path)
+{
+ wxString result(path);
+
+ if ( path.find(' ') != wxString::npos )
+ {
+ result.insert(0, "'");
+ result.append("'");
+ }
+
+ return result;
+}
+
+} // anonymous namespace
+
+bool wxFileTypeImpl::GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const
+{
+ wxString application;
+ if ( !m_manager->GetApplication(m_uti, &application) )
+ return false;
+
+ *openCmd << QuoteIfNecessary(application)
+ << ' ' << QuoteIfNecessary(params.GetFileName());
+
+ return true;
}
bool wxFileTypeImpl::GetPrintCommand(wxString *WXUNUSED(printCmd), const wxFileType::MessageParameters& WXUNUSED(params)) const