diff -r 5d4df7d04f64 -r 360424eab025 MIMETypes.st --- a/MIMETypes.st Thu Feb 09 18:21:44 2017 +0100 +++ b/MIMETypes.st Thu Feb 09 18:24:14 2017 +0100 @@ -315,13 +315,13 @@ |types| FileSuffixToTypeMapping isNil ifTrue:[ - FileSuffixToTypeMapping := Dictionary new + FileSuffixToTypeMapping := Dictionary new:270. ]. TypeToFileSuffixMapping isNil ifTrue:[ - TypeToFileSuffixMapping := Dictionary new + TypeToFileSuffixMapping := Dictionary new:105. ]. FilenameToTypeMapping isNil ifTrue:[ - FilenameToTypeMapping := Dictionary new. + FilenameToTypeMapping := Dictionary new:16. ]. types := OrderedCollection new. @@ -333,32 +333,34 @@ types addAll:self osSpecificTypeList. types pairWiseDo:[:suff :typeString| - |type| + |mimeType| - type := MIMEType fromString:typeString. + mimeType := MIMEType fromString:typeString. suff isArray ifTrue:[ - suff do:[:s | FileSuffixToTypeMapping at:s put:type]. - TypeToFileSuffixMapping at:type put:suff first. + suff do:[:s |FileSuffixToTypeMapping at:s put:mimeType]. + TypeToFileSuffixMapping at:mimeType put:suff first. ] ifFalse:[ - FileSuffixToTypeMapping at:suff put:type. - TypeToFileSuffixMapping at:type put:suff. + FileSuffixToTypeMapping at:suff put:mimeType. + TypeToFileSuffixMapping at:mimeType put:suff. ]. ]. - self miscFilenameList pairWiseDo:[:nm :typeString| - |type| + self miscFilenameList pairWiseDo:[:suffixes :typeString| + |mimeType| - type := MIMEType fromString:typeString. - nm isArray ifTrue:[ - nm do:[:s | FilenameToTypeMapping at:s put:type] + mimeType := MIMEType fromString:typeString. + suffixes isArray ifTrue:[ + suffixes do:[:eachSuffix | FilenameToTypeMapping at:eachSuffix put:mimeType] ] ifFalse:[ - FilenameToTypeMapping at:nm put:type + FilenameToTypeMapping at:suffixes put:mimeType ] ]. " self initializeFileNameToMimeTypeMapping " + + "Modified (format): / 09-02-2017 / 14:59:33 / stefan" ! initializeImageReaderMappings @@ -374,131 +376,133 @@ ]. "/ setup mimeType to image reader class mapping ... - TypeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader. - TypeToImageReaderClassMapping at:'image/gif' put:GIFReader. - TypeToImageReaderClassMapping at:'image/tiff' put:TIFFReader. - TypeToImageReaderClassMapping at:'image/png' put:PNGReader. - TypeToImageReaderClassMapping at:'image/icns' put:MacOSXIconReader. + self imageReaderForType:'image/jpeg' put:JPEGReader. + self imageReaderForType:'image/gif' put:GIFReader. + self imageReaderForType:'image/tiff' put:TIFFReader. + self imageReaderForType:'image/png' put:PNGReader. + self imageReaderForType:'image/icns' put:MacOSXIconReader. "/ setup suffix to image reader class mapping ... - FileSuffixToImageReaderClassMapping at:'jpg' put:JPEGReader. - FileSuffixToImageReaderClassMapping at:'jpeg' put:JPEGReader. - FileSuffixToImageReaderClassMapping at:'gif' put:GIFReader. - FileSuffixToImageReaderClassMapping at:'tif' put:TIFFReader. - FileSuffixToImageReaderClassMapping at:'tiff' put:TIFFReader. - FileSuffixToImageReaderClassMapping at:'png' put:PNGReader. - FileSuffixToImageReaderClassMapping at:'icns' put:MacOSXIconReader. + self imageReaderForSuffix:'jpg' put:JPEGReader. + self imageReaderForSuffix:'jpeg' put:JPEGReader. + self imageReaderForSuffix:'gif' put:GIFReader. + self imageReaderForSuffix:'tif' put:TIFFReader. + self imageReaderForSuffix:'tiff' put:TIFFReader. + self imageReaderForSuffix:'png' put:PNGReader. + self imageReaderForSuffix:'icns' put:MacOSXIconReader. "/ some 'used-to-be-optional' readers (rdr := Smalltalk at:#WindowsIconReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/bmp' put:rdr. - TypeToImageReaderClassMapping at:'image/x-MS-bmp' put:rdr. - TypeToImageReaderClassMapping at:'image/x-ms-bmp' put:rdr. - TypeToImageReaderClassMapping at:'image/x-MS-ico' put:rdr. - TypeToImageReaderClassMapping at:'image/x-ms-ico' put:rdr. - FileSuffixToImageReaderClassMapping at:'bmp' put:rdr. - FileSuffixToImageReaderClassMapping at:'ico' put:rdr. + self imageReaderForType:'image/bmp' put:rdr. + self imageReaderForType:'image/x-MS-bmp' put:rdr. + self imageReaderForType:'image/x-ms-bmp' put:rdr. + self imageReaderForType:'image/x-MS-ico' put:rdr. + self imageReaderForType:'image/x-ms-ico' put:rdr. + self imageReaderForSuffix:'bmp' put:rdr. + self imageReaderForSuffix:'ico' put:rdr. ]. (rdr := Smalltalk at:#XBMReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-xbitmap' put:rdr. - FileSuffixToImageReaderClassMapping at:'xbm' put:rdr. + self imageReaderForType:'image/x-xbitmap' put:rdr. + self imageReaderForSuffix:'xbm' put:rdr. ]. (rdr := Smalltalk at:#XPMReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-xpixmap' put:rdr. - FileSuffixToImageReaderClassMapping at:'pm' put:rdr. + self imageReaderForType:'image/x-xpixmap' put:rdr. + self imageReaderForSuffix:'pm' put:rdr. ]. (rdr := Smalltalk at:#PBMReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-portable-pixmap' put:rdr. - TypeToImageReaderClassMapping at:'image/x-portable-bitmap' put:rdr. - TypeToImageReaderClassMapping at:'image/x-portable-graymap' put:rdr. - TypeToImageReaderClassMapping at:'image/x-portable-anymap' put:rdr. - FileSuffixToImageReaderClassMapping at:'ppm' put:rdr. - FileSuffixToImageReaderClassMapping at:'pbm' put:rdr. - FileSuffixToImageReaderClassMapping at:'pgm' put:rdr. - FileSuffixToImageReaderClassMapping at:'pnm' put:rdr. + self imageReaderForType:'image/x-portable-pixmap' put:rdr. + self imageReaderForType:'image/x-portable-bitmap' put:rdr. + self imageReaderForType:'image/x-portable-graymap' put:rdr. + self imageReaderForType:'image/x-portable-anymap' put:rdr. + self imageReaderForSuffix:'ppm' put:rdr. + self imageReaderForSuffix:'pbm' put:rdr. + self imageReaderForSuffix:'pgm' put:rdr. + self imageReaderForSuffix:'pnm' put:rdr. ]. (rdr := Smalltalk at:#PCXReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-pcx' put:rdr. - FileSuffixToImageReaderClassMapping at:'pcx' put:rdr. + self imageReaderForType:'image/x-pcx' put:rdr. + self imageReaderForSuffix:'pcx' put:rdr. ]. (rdr := Smalltalk at:#TargaReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-targa' put:rdr. - FileSuffixToImageReaderClassMapping at:'tga' put:rdr. + self imageReaderForType:'image/x-targa' put:rdr. + self imageReaderForSuffix:'tga' put:rdr. ]. (rdr := Smalltalk at:#XWDReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-xwindowdump' put:rdr. - TypeToImageReaderClassMapping at:'image/x-windowdump' put:rdr. - FileSuffixToImageReaderClassMapping at:'xwd' put:rdr. + self imageReaderForType:'image/x-xwindowdump' put:rdr. + self imageReaderForType:'image/x-windowdump' put:rdr. + self imageReaderForSuffix:'xwd' put:rdr. ]. (rdr := Smalltalk at:#BlitImageReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-blitimage' put:rdr. - FileSuffixToImageReaderClassMapping at:'48x48x1' put:rdr. + self imageReaderForType:'image/x-blitimage' put:rdr. + self imageReaderForSuffix:'48x48x1' put:rdr. ]. (rdr := Smalltalk at:#IrisRGBReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-rgb' put:rdr. - FileSuffixToImageReaderClassMapping at:'rgb' put:rdr. + self imageReaderForType:'image/x-rgb' put:rdr. + self imageReaderForSuffix:'rgb' put:rdr. ]. (rdr := Smalltalk at:#SunRasterReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-sunraster' put:rdr. - FileSuffixToImageReaderClassMapping at:'im8' put:rdr. - FileSuffixToImageReaderClassMapping at:'icon' put:rdr. + self imageReaderForType:'image/x-sunraster' put:rdr. + self imageReaderForSuffix:'im8' put:rdr. + self imageReaderForSuffix:'icon' put:rdr. ]. (rdr := Smalltalk at:#ST80FormReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-st80-form' put:rdr. - FileSuffixToImageReaderClassMapping at:'form' put:rdr. + self imageReaderForType:'image/x-st80-form' put:rdr. + self imageReaderForSuffix:'form' put:rdr. ]. (rdr := Smalltalk at:#FaceReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-face' put:rdr. - FileSuffixToImageReaderClassMapping at:'face' put:rdr. + self imageReaderForType:'image/x-face' put:rdr. + self imageReaderForSuffix:'face' put:rdr. ]. (rdr := Smalltalk at:#PCDReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-photo-cd' put:rdr. - FileSuffixToImageReaderClassMapping at:'pcd' put:rdr. + self imageReaderForType:'image/x-photo-cd' put:rdr. + self imageReaderForSuffix:'pcd' put:rdr. ]. (rdr := Smalltalk at:#CMURasterReader) notNil ifTrue:[ - TypeToImageReaderClassMapping at:'image/x-cmu-raster' put:rdr. - FileSuffixToImageReaderClassMapping at:'ras' put:rdr. + self imageReaderForType:'image/x-cmu-raster' put:rdr. + self imageReaderForSuffix:'ras' put:rdr. ]. "/ movie formats - experimental and not yet complete / finished / delivered / published "/ (rdr := Smalltalk at:#FLIReader) notNil ifTrue:[ -"/ TypeToImageReaderClassMapping at:'video/x-fli' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'fli' put:rdr. +"/ self imageReaderForType:'video/x-fli' put:rdr. +"/ self imageReaderForSuffix:'fli' put:rdr. "/ ]. "/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ -"/ TypeToImageReaderClassMapping at:'video/x-msvideo' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'avi' put:rdr. +"/ self imageReaderForType:'video/x-msvideo' put:rdr. +"/ self imageReaderForSuffix:'avi' put:rdr. "/ ]. "/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ -"/ TypeToImageReaderClassMapping at:'video/x-msvideo' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'avi' put:rdr. +"/ self imageReaderForType:'video/x-msvideo' put:rdr. +"/ self imageReaderForSuffix:'avi' put:rdr. "/ ]. "/ (rdr := Smalltalk at:#QuickTimeReader) notNil ifTrue:[ -"/ TypeToImageReaderClassMapping at:'video/quicktime' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'qt' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mov' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'moov' put:rdr. +"/ self imageReaderForType:'video/quicktime' put:rdr. +"/ self imageReaderForSuffix:'qt' put:rdr. +"/ self imageReaderForSuffix:'mov' put:rdr. +"/ self imageReaderForSuffix:'moov' put:rdr. "/ ]. "/ (rdr := Smalltalk at:#MPEG2Reader) notNil ifTrue:[ -"/ TypeToImageReaderClassMapping at:'video/x-mpeg2' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mpg2' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mpv2' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mp2v' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mp2' put:rdr. +"/ self imageReaderForType:'video/x-mpeg2' put:rdr. +"/ self imageReaderForSuffix:'mpg2' put:rdr. +"/ self imageReaderForSuffix:'mpv2' put:rdr. +"/ self imageReaderForSuffix:'mp2v' put:rdr. +"/ self imageReaderForSuffix:'mp2' put:rdr. "/ ]. "/ (rdr := Smalltalk at:#MPEGReader) notNil ifTrue:[ -"/ TypeToImageReaderClassMapping at:'video/mpeg' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mpg' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mpeg' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mpe' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mpv' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'vps' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'mpegv' put:rdr. +"/ self imageReaderForType:'video/mpeg' put:rdr. +"/ self imageReaderForSuffix:'mpg' put:rdr. +"/ self imageReaderForSuffix:'mpeg' put:rdr. +"/ self imageReaderForSuffix:'mpe' put:rdr. +"/ self imageReaderForSuffix:'mpv' put:rdr. +"/ self imageReaderForSuffix:'vps' put:rdr. +"/ self imageReaderForSuffix:'mpegv' put:rdr. "/ ]. "/ (rdr := Smalltalk at:#SGIMovieReader) notNil ifTrue:[ -"/ TypeToImageReaderClassMapping at:'video/x-sgi-movie' put:rdr. -"/ FileSuffixToImageReaderClassMapping at:'movie' put:rdr. +"/ self imageReaderForType:'video/x-sgi-movie' put:rdr. +"/ self imageReaderForSuffix:'movie' put:rdr. "/ ]. + + "Modified (format): / 09-02-2017 / 15:46:48 / stefan" ! initializeParenthesisSpecMappings @@ -584,19 +588,20 @@ ^ #( "/ the first column is a list of extensions, the second the more-or-less official mimetype - ('a' 'o' 'obj' ) 'application/binary' - ('lic') 'application/license' - ('dll' 'so') 'application/shared-library' + ('a' 'o' 'obj' ) 'application/binary' + 'lic' 'application/license' + ('dll' 'so') 'application/shared-library' - ('ets') 'application/x-expecco-testsuite' - ('etr') 'application/x-expecco-testrepository' - ('elf') 'application/x-expecco-logfile' - ('expeccolicense') 'application/x-expecco-license' - ('expeccopatch') 'application/x-expecco-patch' + 'ets' 'application/x-expecco-testsuite' + 'etr' 'application/x-expecco-testrepository' + 'elf' 'application/x-expecco-logfile' + 'expeccolicense' 'application/x-expecco-license' + 'expeccopatch' 'application/x-expecco-patch' ) "Modified: / 03-11-2011 / 10:42:28 / sr" "Modified (format): / 05-02-2017 / 19:37:05 / cg" + "Modified: / 09-02-2017 / 14:31:45 / stefan" ! applicationProgLangTypeList @@ -694,7 +699,7 @@ "/ the first column is a list of extensions, the second the more-or-less official mimetype ('au' 'snd') 'audio/basic' - ('ra') 'audio/x-realaudio' + 'ra' 'audio/x-realaudio' ('ram' 'rm') 'audio/x-pn-realaudio' "/ cg: see unixSpecific / windowsSpecific "/ 'rpm' 'audio/x-pn-realaudio-plugin' @@ -708,6 +713,7 @@ "Modified: / 26-05-2012 / 15:23:45 / cg" "Modified (comment): / 05-02-2017 / 19:37:48 / cg" + "Modified: / 09-02-2017 / 14:29:59 / stefan" ! imageTypeList @@ -990,20 +996,13 @@ "/ allow for fallback ... type := OperatingSystem mimeTypeForSuffix:lcSuffix. "/ the special value #unknown is returned as nil; - "/ this avoids constant retry if a mimeType is not known in the OS. - - type := type ? #unknown. + "/ this avoids constant retry if a suffix is not known in the OS. + type := type isNil ifTrue:[#unknown] ifFalse:[MIMEType fromString:type]. FileSuffixToTypeMapping at:lcSuffix put:type. ]. - type == #unknown ifTrue:[ - type := nil. - ]. - type notNil ifTrue:[ - LastSuffix := suffix. - LastType := MIMEType fromString:type. - ^ LastType - ]. + LastSuffix := suffix. + LastType := type. ^ type " @@ -1014,6 +1013,7 @@ "Created: / 30-06-1997 / 21:55:51 / cg" "Modified: / 14-02-2011 / 17:14:34 / cg" + "Modified: / 09-02-2017 / 14:57:52 / stefan" ! mimeTypeForSuffix:suffix put:mimeType @@ -1022,10 +1022,11 @@ FileSuffixToTypeMapping isNil ifTrue:[ FileSuffixToTypeMapping := Dictionary new ]. - FileSuffixToTypeMapping at:suffix put:mimeType asLowercase + FileSuffixToTypeMapping at:suffix ifAbsentPut:[MIMEType fromString:mimeType asLowercase]. - "Created: / 30.6.1997 / 21:56:20 / cg" - "Modified: / 1.8.1998 / 17:03:18 / cg" + "Created: / 30-06-1997 / 21:56:20 / cg" + "Modified: / 01-08-1998 / 17:03:18 / cg" + "Modified: / 09-02-2017 / 15:09:17 / stefan" ! mimeTypeForSuffixMapping @@ -1286,23 +1287,14 @@ imageReaderClasses "return a collection of registered image reader classes" - |setOfClasses| - - setOfClasses := IdentitySet new. - FileSuffixToImageReaderClassMapping notNil ifTrue:[ - FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls | - setOfClasses add:cls - ]. + TypeToImageReaderClassMapping notNil ifTrue:[ + ^ TypeToImageReaderClassMapping values asSet. ]. - TypeToImageReaderClassMapping notNil ifTrue:[ - TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls | - setOfClasses add:cls - ]. - ]. - ^ setOfClasses + ^ #(). - "Created: / 30.6.1997 / 22:03:42 / cg" - "Modified: / 1.8.1998 / 16:59:52 / cg" + "Created: / 30-06-1997 / 22:03:42 / cg" + "Modified: / 01-08-1998 / 16:59:52 / cg" + "Modified: / 09-02-2017 / 15:23:52 / stefan" ! imageReaderForSuffix:aSuffix @@ -1347,10 +1339,13 @@ TypeToImageReaderClassMapping isNil ifTrue:[ self initializeImageReaderMappings ]. - TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass + TypeToImageReaderClassMapping + at:(MIMEType fromString:mimeTypeString asLowercase) + put:aReaderClass - "Created: / 30.6.1997 / 21:56:11 / cg" - "Modified: / 1.8.1998 / 17:02:40 / cg" + "Created: / 30-06-1997 / 21:56:11 / cg" + "Modified: / 01-08-1998 / 17:02:40 / cg" + "Modified: / 09-02-2017 / 15:32:58 / stefan" ! ! !MIMETypes class methodsFor:'queries-language syntax'! @@ -1533,10 +1528,12 @@ ^ newType " + CachedTypes := nil. self fromString:'text/html' " "Modified: / 20-07-2012 / 17:36:31 / cg" + "Modified (comment): / 09-02-2017 / 15:36:06 / stefan" ! ! !MIMETypes::MIMEType methodsFor:'queries'!