]> git.saurik.com Git - wxWidgets.git/commitdiff
wxMimeTypesManagerImpl::GetFileTypeFromMimeType() implemented
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 21 Jan 1999 12:47:04 +0000 (12:47 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 21 Jan 1999 12:47:04 +0000 (12:47 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1442 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/mimetype.cpp

index 1e268d586d11ac160430a46bc9f3650c1afc592c..513c35b3fc55598bf995591537ae626186ed86f4 100644 (file)
@@ -796,8 +796,25 @@ wxMimeTypesManagerImpl::wxMimeTypesManagerImpl()
 wxFileType *
 wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext)
 {
-    wxFAIL_MSG("not implemented (must parse mime.types)");
+    size_t count = m_aExtensions.GetCount();
+    for ( size_t n = 0; n < count; n++ ) {
+        wxString extensions = m_aExtensions[n];
+        while ( !extensions.IsEmpty() ) {
+            wxString field = extensions.BeforeFirst(' ');
+            extensions = extensions.AfterFirst(' ');
+
+            // consider extensions as not being case-sensitive
+            if ( field.IsSameAs(ext, FALSE /* no case */) ) { 
+                // found
+                wxFileType *fileType = new wxFileType;
+                fileType->m_impl->Init(this, n);
+                
+                return fileType;
+            }
+        }
+    }
 
+    // not found
     return NULL;
 }