-#ifdef __WXMSW__
- // this writes a root entry to the registry in HKCR.ext
- return m_impl->GetOrAllocateFileTypeFromExtension(ext);
-#else // !__WXMSW__
- // VZ: "static const"??? (FIXME)
- // just make a dummy entry with no writing to file
- static const wxFileTypeInfo fallback[] =
- {
- wxFileTypeInfo("application/x-" + ext,
- "",
- "",
- ext + " format file",
- ext, NULL),
- // must terminate the table with this!
- wxFileTypeInfo()
- };
+ wxString::const_iterator i = ext.begin();
+ const wxString::const_iterator end = ext.end();
+ wxString extWithoutDot;
+ if ( i != end && *i == '.' )
+ extWithoutDot.assign(++i, ext.end());
+ else
+ extWithoutDot = ext;
+
+ wxCHECK_MSG( !ext.empty(), NULL, _T("extension can't be empty") );
+
+ wxFileType *ft = m_impl->GetFileTypeFromExtension(extWithoutDot);
+
+ if ( !ft ) {
+ // check the fallbacks
+ //
+ // TODO linear search is potentially slow, perhaps we should use a
+ // sorted array?
+ size_t count = m_fallbacks.GetCount();
+ for ( size_t n = 0; n < count; n++ ) {
+ if ( m_fallbacks[n].GetExtensions().Index(ext) != wxNOT_FOUND ) {
+ ft = new wxFileType(m_fallbacks[n]);
+
+ break;
+ }
+ }
+ }