ensure minimal mime support in wxHTML even without wxMimeTypesMananger
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13847 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -41,29 +41,36 @@ static wxFileTypeInfo *gs_FSMimeFallbacks = NULL;
|
|||||||
|
|
||||||
wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
|
wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
|
||||||
{
|
{
|
||||||
#if wxUSE_MIMETYPE
|
wxString ext, mime;
|
||||||
wxString ext = wxEmptyString, mime = wxEmptyString;
|
|
||||||
wxString loc = GetRightLocation(location);
|
wxString loc = GetRightLocation(location);
|
||||||
char c;
|
char c;
|
||||||
int l = loc.Length(), l2;
|
int l = loc.Length(), l2;
|
||||||
wxFileType *ft;
|
|
||||||
|
|
||||||
l2 = l;
|
l2 = l;
|
||||||
for (int i = l-1; i >= 0; i--) {
|
for (int i = l-1; i >= 0; i--)
|
||||||
|
{
|
||||||
c = loc[(unsigned int) i];
|
c = loc[(unsigned int) i];
|
||||||
if (c == wxT('#')) l2 = i + 1;
|
if ( c == wxT('#') )
|
||||||
if (c == wxT('.')) {ext = loc.Right(l2-i-1); break;}
|
l2 = i + 1;
|
||||||
if ((c == wxT('/')) || (c == wxT('\\')) || (c == wxT(':'))) {return wxEmptyString;}
|
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;
|
static bool s_MinimalMimeEnsured = FALSE;
|
||||||
if (!s_MinimalMimeEnsured) {
|
if (!s_MinimalMimeEnsured) {
|
||||||
wxTheMimeTypesManager->AddFallbacks(gs_FSMimeFallbacks);
|
wxTheMimeTypesManager->AddFallbacks(gs_FSMimeFallbacks);
|
||||||
s_MinimalMimeEnsured = TRUE;
|
s_MinimalMimeEnsured = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ft = wxTheMimeTypesManager -> GetFileTypeFromExtension(ext);
|
wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
|
||||||
if ( !ft || !ft -> GetMimeType(&mime) ) {
|
if ( !ft || !ft -> GetMimeType(&mime) )
|
||||||
|
{
|
||||||
mime = wxEmptyString;
|
mime = wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +78,16 @@ wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
|
|||||||
|
|
||||||
return mime;
|
return mime;
|
||||||
#else
|
#else
|
||||||
|
if ( ext.IsSameAs(wxT("htm"), FALSE) || ext.IsSameAs(_T("html"), FALSE) )
|
||||||
|
return wxT("text/html");
|
||||||
|
if ( ext.IsSameAs(wxT("jpg"), FALSE) || ext.IsSameAs(_T("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;
|
return wxEmptyString;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user