wxMimeTypeManager::EnumAll() seems to work, couple of minor corrections to the MIME code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4858 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-12-07 15:18:22 +00:00
parent 7799a2d76f
commit 54acce9084
2 changed files with 39 additions and 20 deletions

View File

@@ -82,7 +82,8 @@ static void TestMimeEnum()
extsAll += exts[e]; extsAll += exts[e];
} }
printf("\t%s: %s (%s)\n", mimetypes[n], desc, extsAll); printf("\t%s: %s (%s)\n",
mimetypes[n].c_str(), desc.c_str(), extsAll.c_str());
} }
} }

View File

@@ -1401,8 +1401,8 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
while ( wxIsspace(*pc) ) while ( wxIsspace(*pc) )
pc++; pc++;
// comment? // comment or blank line?
if ( *pc == wxT('#') ) { if ( *pc == wxT('#') || !*pc ) {
// skip the whole line // skip the whole line
pc = NULL; pc = NULL;
continue; continue;
@@ -1681,16 +1681,21 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
if ( !ok ) if ( !ok )
{ {
// don't flood the user with error messages // we don't understand this field, but
// if we don't understand something in his // Netscape stores info in it, so don't warn
// mailcap, but give them in debug mode // about it
// because this might be useful for the if ( curField.Left(16u) != "x-mozilla-flags=" )
// programmer {
// don't flood the user with error
// messages if we don't understand
// something in his mailcap, but give
// them in debug mode because this might
// be useful for the programmer
wxLogDebug wxLogDebug
( (
wxT("Mailcap file %s, line %d: unknown " wxT("Mailcap file %s, line %d: "
"field '%s' for the MIME type " "unknown field '%s' for the "
"'%s' ignored."), "MIME type '%s' ignored."),
strFileName.c_str(), strFileName.c_str(),
nLine + 1, nLine + 1,
curField.c_str(), curField.c_str(),
@@ -1698,6 +1703,7 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
); );
} }
} }
}
// it already has this value // it already has this value
//currentToken = Field_Other; //currentToken = Field_Other;
@@ -1801,9 +1807,21 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes) size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
{ {
mimetypes = m_aTypes; mimetypes.Empty();
return m_aTypes.GetCount(); wxString type;
size_t count = m_aTypes.GetCount();
for ( size_t n = 0; n < count; n++ )
{
// don't return template types from here (i.e. anything containg '*')
type = m_aTypes[n];
if ( type.Find(_T('*')) == wxNOT_FOUND )
{
mimetypes.Add(type);
}
}
return mimetypes.GetCount();
} }
#endif #endif