]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/mimetype.cpp
1. more C++ parser fixes - now it almost parses wx/string.h
[wxWidgets.git] / src / common / mimetype.cpp
index 9c9232276fe818237d1fb1438fa4b22036f36c18..e4dcc9cf34583143eb1f451694ffe38670a9c94e 100644 (file)
@@ -448,6 +448,28 @@ wxFileType::GetPrintCommand(wxString *printCmd,
 // wxMimeTypesManager
 // ----------------------------------------------------------------------------
 
+bool wxMimeTypesManager::IsOfType(const wxString& mimeType,
+                                  const wxString& wildcard)
+{
+    wxASSERT_MSG( mimeType.Find('*') == wxNOT_FOUND,
+                  "first MIME type can't contain wildcards" );
+
+    // all comparaisons are case insensitive (2nd arg of IsSameAs() is FALSE)
+    if ( wildcard.BeforeFirst('/').IsSameAs(mimeType.BeforeFirst('/'), FALSE) )
+    {
+        wxString strSubtype = wildcard.AfterFirst('/');
+
+        if ( strSubtype == '*' ||
+             strSubtype.IsSameAs(mimeType.AfterFirst('/'), FALSE) )
+        {
+            // matches (either exactly or it's a wildcard)
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
 wxMimeTypesManager::wxMimeTypesManager()
 {
     m_impl = new wxMimeTypesManagerImpl;
@@ -1148,9 +1170,9 @@ void wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName)
                                     // programmer
                                     wxLogDebug
                                     (
-                                      _("Mailcap file %s, line %d: unknown "
-                                        "field '%s' for the MIME type "
-                                        "'%s' ignored."),
+                                      "Mailcap file %s, line %d: unknown "
+                                      "field '%s' for the MIME type "
+                                      "'%s' ignored.",
                                       strFileName.c_str(),
                                       nLine + 1,
                                       curField.c_str(),