+ for (int i = l-1; i >= 0; i--)
+ {
+ c = loc[(unsigned int) i];
+ if ( c == wxT('#') )
+ l2 = i + 1;
+ if ( c == wxT('.') )
+ {
+ ext = loc.Right(l2-i-1);
+ break;
+ }
+ if ( (c == wxT('/')) || (c == wxT('\\')) || (c == wxT(':')) )
+ return wxEmptyString;
+ }
+
+#if wxUSE_MIMETYPE
+ static bool s_MinimalMimeEnsured = false;
+
+ // Don't use mime types manager if the application doesn't need it and it would be
+ // cause an unacceptable delay, especially on startup.
+#if wxUSE_SYSTEM_OPTIONS
+ if ( !wxSystemOptions::GetOptionInt(wxT("filesys.no-mimetypesmanager")) )
+#endif
+ {
+ if (!s_MinimalMimeEnsured)
+ {
+ static const wxFileTypeInfo fallbacks[] =
+ {
+ wxFileTypeInfo(wxT("image/jpeg"),
+ wxEmptyString,
+ wxEmptyString,
+ wxT("JPEG image (from fallback)"),
+ wxT("jpg"), wxT("jpeg"), wxT("JPG"), wxT("JPEG"), wxNullPtr),
+ wxFileTypeInfo(wxT("image/gif"),
+ wxEmptyString,
+ wxEmptyString,
+ wxT("GIF image (from fallback)"),
+ wxT("gif"), wxT("GIF"), wxNullPtr),
+ wxFileTypeInfo(wxT("image/png"),
+ wxEmptyString,
+ wxEmptyString,
+ wxT("PNG image (from fallback)"),
+ wxT("png"), wxT("PNG"), wxNullPtr),
+ wxFileTypeInfo(wxT("image/bmp"),
+ wxEmptyString,
+ wxEmptyString,
+ wxT("windows bitmap image (from fallback)"),
+ wxT("bmp"), wxT("BMP"), wxNullPtr),
+ wxFileTypeInfo(wxT("text/html"),
+ wxEmptyString,
+ wxEmptyString,
+ wxT("HTML document (from fallback)"),
+ wxT("htm"), wxT("html"), wxT("HTM"), wxT("HTML"), wxNullPtr),
+ // must terminate the table with this!
+ wxFileTypeInfo()
+ };
+ wxTheMimeTypesManager->AddFallbacks(fallbacks);
+ s_MinimalMimeEnsured = true;
+ }
+
+ wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
+ if ( !ft || !ft -> GetMimeType(&mime) )
+ {
+ mime = wxEmptyString;
+ }
+
+ delete ft;
+
+ return mime;
+ }
+ else
+#endif
+ {
+ if ( ext.IsSameAs(wxT("htm"), false) || ext.IsSameAs(wxT("html"), false) )
+ return wxT("text/html");
+ if ( ext.IsSameAs(wxT("jpg"), false) || ext.IsSameAs(wxT("jpeg"), false) )
+ return wxT("image/jpeg");
+ if ( ext.IsSameAs(wxT("gif"), false) )
+ return wxT("image/gif");
+ if ( ext.IsSameAs(wxT("png"), false) )
+ return wxT("image/png");
+ if ( ext.IsSameAs(wxT("bmp"), false) )
+ return wxT("image/bmp");
+ return wxEmptyString;