--- a/MIMETypes.st Thu Jan 15 13:45:11 2004 +0100
+++ b/MIMETypes.st Fri Jan 16 16:00:43 2004 +0100
@@ -18,9 +18,9 @@
instanceVariableNames:''
classVariableNames:'TypeToImageReaderClassMapping TypeToCommentStringMapping
SuffixToCommentStringMapping FileSuffixToTypeMapping
- FilenameToTypeMapping FileSuffixToImageReaderClassMapping
- CharSetToFontMapping LastSuffix LastType
- DefaultCommandPerMIMEPerOS'
+ TypeToFileSuffixMapping FilenameToTypeMapping
+ FileSuffixToImageReaderClassMapping CharSetToFontMapping
+ LastSuffix LastType DefaultCommandPerMIMEPerOS'
poolDictionaries:''
category:'Net-Communication-Support'
!
@@ -198,6 +198,9 @@
FileSuffixToTypeMapping isNil ifTrue:[
FileSuffixToTypeMapping := Dictionary new
].
+ TypeToFileSuffixMapping isNil ifTrue:[
+ TypeToFileSuffixMapping := Dictionary new
+ ].
FilenameToTypeMapping isNil ifTrue:[
FilenameToTypeMapping := Dictionary new.
].
@@ -213,10 +216,12 @@
type := MIMEType fromString:typeString.
suff isArray ifTrue:[
- suff do:[:s | FileSuffixToTypeMapping at:s put:type]
+ suff do:[:s | FileSuffixToTypeMapping at:s put:type].
+ TypeToFileSuffixMapping at:type put:suff first.
] ifFalse:[
- FileSuffixToTypeMapping at:suff put:type
- ]
+ FileSuffixToTypeMapping at:suff put:type.
+ TypeToFileSuffixMapping at:type put:suff.
+ ].
].
self miscFilenameList pairWiseDo:[:nm :typeString|
@@ -394,8 +399,7 @@
"/ misc text ...
^ #(
- ('htm' 'html') 'text/html'
- 'shtml' 'text/html'
+ ('html' 'htm' 'shtml') 'text/html'
('txt' 'text') 'text/plain'
'xml' 'text/xml'
'css' 'text/css'
@@ -602,6 +606,32 @@
typeString := filename mimeTypeOfContents.
typeString isNil ifTrue:[^ nil].
^ MIMEType fromString:typeString.
+!
+
+suffixForMimeType:mimeType
+ "given a file suffix, return the mime-type"
+
+ ^ TypeToFileSuffixMapping at:mimeType ifAbsent:nil
+
+ "
+ self suffixForMimeType:(MIMEType fromString:'image/gif')
+ "
+
+ "Created: / 30.6.1997 / 21:55:51 / cg"
+ "Modified: / 23.12.1999 / 22:30:55 / cg"
+!
+
+suffixForMimeTypeString:mimeTypeString
+ "given a file suffix, return the mime-type"
+
+ ^ self suffixForMimeType:(MIMEType fromString:mimeTypeString)
+
+ "
+ self suffixForMimeTypeString:'image/gif'
+ "
+
+ "Created: / 30.6.1997 / 21:55:51 / cg"
+ "Modified: / 23.12.1999 / 22:30:55 / cg"
! !
!MIMETypes class methodsFor:'queries-image formats'!
@@ -853,7 +883,7 @@
!MIMETypes class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.66 2003-12-02 10:06:45 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.67 2004-01-16 15:00:43 penk Exp $'
! !
MIMETypes initialize!