add a new flag so mime types aren't added to the mapper if they are not found.

This commit is contained in:
pinkerton%netscape.com 1999-09-05 02:27:54 +00:00
Родитель dcb880ceae
Коммит 21ae722449
2 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -59,7 +59,7 @@ nsMimeMapperMac :: ~nsMimeMapperMac ( )
// be exported along with the data.
//
ResType
nsMimeMapperMac :: MapMimeTypeToMacOSType ( const char* aMimeStr )
nsMimeMapperMac :: MapMimeTypeToMacOSType ( const char* aMimeStr, PRBool inAddIfNotPresent )
{
ResType format = 0;
@ -79,7 +79,7 @@ nsMimeMapperMac :: MapMimeTypeToMacOSType ( const char* aMimeStr )
if ( !format ) {
if ( PL_strcmp(aMimeStr, kTextMime) == 0 )
format = 'TEXT';
else {
else if ( inAddIfNotPresent ) {
// create the flavor based on the unique id in the lower two bytes and 'MZ' in the
// upper two bytes.
format = mCounter++;
@ -91,7 +91,8 @@ nsMimeMapperMac :: MapMimeTypeToMacOSType ( const char* aMimeStr )
}
NS_ASSERTION ( format, "Didn't map mimeType to a macOS type for some reason" );
if ( inAddIfNotPresent )
NS_ASSERTION ( format, "Didn't map mimeType to a macOS type for some reason" );
return format;
} // MapMimeTypeToMacOSType

Просмотреть файл

@ -59,8 +59,9 @@ public:
nsMimeMapperMac ( const char* inMappings ) ;
~nsMimeMapperMac ( ) ;
// Converts from mime type (eg: text/plain) to MacOS type (eg: 'TEXT').
ResType MapMimeTypeToMacOSType ( const char* aMimeStr ) ;
// Converts from mime type (eg: text/plain) to MacOS type (eg: 'TEXT'). If
// the mapping failed, the resulting restype will be null.
ResType MapMimeTypeToMacOSType ( const char* aMimeStr, PRBool inAddIfNotPresent = PR_TRUE ) ;
void MapMacOSTypeToMimeType ( ResType inMacType, nsCAutoString & outMimeStr ) ;
// Takes the internal mappings and converts them to a string for