author | Claus Gittinger <cg@exept.de> |
Wed, 04 Jun 2008 11:06:22 +0200 | |
changeset 2489 | b891d96fd496 |
parent 2487 | eaa224da42fa |
child 2490 | 9bcc1b3fd7e0 |
permissions | -rw-r--r-- |
643 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
1612 | 3 |
All Rights Reserved |
643 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1410 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
643 | 14 |
Object subclass:#MIMETypes |
1612 | 15 |
instanceVariableNames:'' |
1729 | 16 |
classVariableNames:'TypeToImageReaderClassMapping TypeToCommentStringMapping |
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
17 |
TypeToFileSuffixMapping TypeToViewerApplicationMapping |
1729 | 18 |
SuffixToCommentStringMapping FileSuffixToTypeMapping |
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
19 |
FilenameToTypeMapping FileSuffixToImageReaderClassMapping |
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
20 |
CharSetToFontMapping LastSuffix LastType |
2298 | 21 |
DefaultCommandPerMIMEPerOS DefaultPrintCommandPerMIMEPerOS |
22 |
TypeToParentesisSpecMapping SuffixToParentesisSpecMapping' |
|
1612 | 23 |
poolDictionaries:'' |
1800 | 24 |
category:'Net-Communication-Support' |
1612 | 25 |
! |
26 |
||
27 |
String variableByteSubclass:#MIMEType |
|
28 |
instanceVariableNames:'' |
|
29 |
classVariableNames:'CachedTypes' |
|
30 |
poolDictionaries:'' |
|
31 |
privateIn:MIMETypes |
|
643 | 32 |
! |
33 |
||
34 |
!MIMETypes class methodsFor:'documentation'! |
|
35 |
||
36 |
copyright |
|
37 |
" |
|
38 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
1612 | 39 |
All Rights Reserved |
643 | 40 |
|
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
||
48 |
||
49 |
" |
|
50 |
! |
|
51 |
||
52 |
documentation |
|
53 |
" |
|
54 |
just a place to keep MIME information |
|
55 |
(avoid spreading things at many places) |
|
56 |
||
1021 | 57 |
MIMETypes is abstract and functional. |
58 |
Actually, in some OperatingSystems, this information may |
|
59 |
be found in some config files (or registries). |
|
60 |
Therefore, this class may have to be extended to support this |
|
61 |
and fetch the information from there eventually. |
|
62 |
||
643 | 63 |
[author:] |
64 |
Claus Gittinger |
|
65 |
" |
|
1311 | 66 |
! |
67 |
||
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
68 |
examples |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
69 |
" |
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
70 |
MIMETypes mimeTypeFromString:'application/x-expecco-testsuite' |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
71 |
|
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
72 |
MIMETypes mimeTypeForSuffix:'gif' |
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
73 |
MIMETypes mimeTypeForSuffix:'ets' |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
74 |
" |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
75 |
! |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
76 |
|
1311 | 77 |
knownTypes |
78 |
" |
|
79 |
simply a reminder for me ... |
|
80 |
||
81 |
application mime file extentsions |
|
82 |
||
83 |
powerpoint application/ms-powerpoint .pot, .ppz, .ppt, .pps, |
|
84 |
application/mspowerpoint |
|
85 |
application/vnd.ms-powerpoint |
|
86 |
application/x-mspowerpoint |
|
87 |
||
1312 | 88 |
shockwave application/x-shockwave-flash .swf |
1311 | 89 |
|
1312 | 90 |
futuresplash application/futuresplash .spl |
1311 | 91 |
" |
643 | 92 |
! ! |
93 |
||
94 |
!MIMETypes class methodsFor:'initialization'! |
|
95 |
||
1729 | 96 |
initialize |
97 |
"initialize wellKnown facts" |
|
98 |
||
99 |
MIMEType initialize. "must be initialized first" |
|
100 |
LastSuffix := LastType := nil. |
|
101 |
||
102 |
self initializeFileNameToMimeTypeMapping. |
|
103 |
self initializeImageReaderMappings. |
|
104 |
self initializeCommentStringMappings. |
|
2298 | 105 |
self initializeParentesisSpecMappings. |
1729 | 106 |
|
107 |
" |
|
108 |
self initialize |
|
109 |
" |
|
110 |
||
2298 | 111 |
"Modified: / 10-04-2007 / 15:16:44 / cg" |
1729 | 112 |
! |
113 |
||
114 |
initializeCommentStringMappings |
|
115 |
TypeToCommentStringMapping := Dictionary new. |
|
116 |
SuffixToCommentStringMapping := Dictionary new. |
|
117 |
||
118 |
TypeToCommentStringMapping |
|
119 |
at:'application/x-make' |
|
120 |
put:#('#' (nil nil)). "/ '#' for EOL comments only |
|
121 |
||
122 |
TypeToCommentStringMapping |
|
123 |
at:'application/x-sh' |
|
124 |
put:#('#' (nil nil)). "/ '#' for EOL comments only |
|
125 |
||
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
126 |
#('text/html' 'text/xml' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
127 |
'application/xml' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
128 |
'application/x-expecco-testsuite' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
129 |
'application/x-expecco-logfile' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
130 |
) |
1729 | 131 |
do:[:eachXMLType | |
132 |
TypeToCommentStringMapping |
|
133 |
at:eachXMLType |
|
134 |
put:#(nil ('<!!-- ' ' -->')). "/ '<!!-- ... -->' delimited comments only |
|
135 |
]. |
|
136 |
||
137 |
TypeToCommentStringMapping |
|
2055 | 138 |
at:'text/css' |
139 |
put:#('//' ('/*' '*/')). |
|
140 |
||
141 |
TypeToCommentStringMapping |
|
1729 | 142 |
at:'application/x-batch-script' |
143 |
put:#('rem ' (nil nil)). "/ 'rem ' for EOL comments only |
|
144 |
||
145 |
"/ the following is ST/X specific |
|
146 |
TypeToCommentStringMapping |
|
147 |
at:'application/x-smalltalk-source' |
|
148 |
put:#('"/' ('"' '"')). "/ '"/ ' for EOL; ".." for delimited comments |
|
149 |
||
2055 | 150 |
|
1729 | 151 |
"/ this is for standard smalltalk |
152 |
"/ TypeToCommentStringMapping |
|
153 |
"/ at:'application/x-smalltalk-source' |
|
154 |
"/ put:#(nil ('"' '"')). "/ ".." for delimited comments only |
|
155 |
||
156 |
||
157 |
TypeToCommentStringMapping |
|
158 |
at:'application/x-pascal-source' |
|
159 |
put:#(nil ('{' '}')). "/ '{'..'}' for delimited comments |
|
160 |
||
2055 | 161 |
|
2048
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
162 |
"/ "/ the following is k&r |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
163 |
"/ TypeToCommentStringMapping |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
164 |
"/ at:'application/x-c-source' |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
165 |
"/ put:#(nil ('/*' '*/')). "/ '/*'..'*/' for delimited comments |
1729 | 166 |
"/ this is ANSI-c |
167 |
TypeToCommentStringMapping |
|
168 |
at:'application/x-c-source' |
|
169 |
put:#('//' ('/*' '*/')). |
|
170 |
||
171 |
TypeToCommentStringMapping |
|
172 |
at:'application/x-cpp-source' |
|
173 |
put:#('//' ('/*' '*/')). |
|
174 |
||
175 |
TypeToCommentStringMapping |
|
2479 | 176 |
at:'application/x-csharp-source' |
177 |
put:#('//' ('/*' '*/')). |
|
178 |
||
179 |
TypeToCommentStringMapping |
|
1729 | 180 |
at:'application/x-java-source' |
181 |
put:#('//' ('/*' '*/')). |
|
182 |
||
183 |
TypeToCommentStringMapping |
|
2048
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
184 |
at:'application/x-javascript' |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
185 |
put:#('//' ('/*' '*/')). |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
186 |
|
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
187 |
TypeToCommentStringMapping |
2298 | 188 |
at:'application/x-lisp-source' |
189 |
put:#(';' (nil nil)). "/ '#' for EOL comments only |
|
190 |
||
191 |
TypeToCommentStringMapping |
|
1729 | 192 |
at:'application/x-asn1-source' |
193 |
put:#('--' ('--' '--')). |
|
194 |
||
195 |
||
196 |
"/ st/x support files |
|
197 |
SuffixToCommentStringMapping |
|
198 |
at:'style' |
|
199 |
put:#(';' (nil nil)). |
|
1604 | 200 |
|
1729 | 201 |
SuffixToCommentStringMapping |
202 |
at:'rs' |
|
2298 | 203 |
put:#(';' (nil nil)). |
204 |
||
205 |
"Modified: / 07-04-2007 / 16:12:05 / cg" |
|
1729 | 206 |
! |
207 |
||
208 |
initializeDefaultCommands |
|
209 |
"TODO: move this to OS" |
|
210 |
||
2116 | 211 |
|unixCommands win32Commands unixPrintCommands win32PrintCommands| |
1729 | 212 |
|
213 |
DefaultCommandPerMIMEPerOS := Dictionary new. |
|
214 |
DefaultCommandPerMIMEPerOS at:#unix put:(unixCommands := Dictionary new). |
|
215 |
DefaultCommandPerMIMEPerOS at:#win32 put:(win32Commands := Dictionary new). |
|
216 |
||
217 |
unixCommands at:'application/x-tar-compressed' put:'gunzip < %1 | tar tvf -'. |
|
218 |
unixCommands at:'application/pdf' put:'acroread -display %2 %1'. |
|
219 |
||
2141 | 220 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |cmd| |
2142 | 221 |
cmd := #( firefox konqueror mozilla netscape opera ) |
2141 | 222 |
detect:[:aCmd| (OperatingSystem pathOfCommand:aCmd) notEmptyOrNil ] |
223 |
ifNone:nil. |
|
224 |
||
225 |
cmd notNil ifTrue:[ |
|
2142 | 226 |
unixCommands at:'text/html' put:(cmd, ' "%1"') |
2141 | 227 |
]. |
228 |
]. |
|
229 |
||
230 |
||
2116 | 231 |
DefaultPrintCommandPerMIMEPerOS := Dictionary new. |
232 |
DefaultPrintCommandPerMIMEPerOS at:#unix put:(unixPrintCommands := Dictionary new). |
|
233 |
DefaultPrintCommandPerMIMEPerOS at:#win32 put:(win32PrintCommands := Dictionary new). |
|
234 |
||
235 |
"/ if you have a good (intelligent) spooler ;-) |
|
236 |
unixPrintCommands at:'application/pdf' put:'lpr %1'. |
|
237 |
"/ if not, you may need more... |
|
238 |
"/ unixPrintCommands at:'application/pdf' put:'pdfToPS %1 | lpr'. |
|
239 |
||
240 |
"/ WIN32 setup is now obsolete - now read through the registry |
|
2096 | 241 |
"/ OperatingSystem isMSWINDOWSlike ifTrue:[ |
242 |
"/ #( |
|
243 |
"/ "suffix" "default" "mime" |
|
244 |
"/ ( 'pdf' 'acrord32 %1' 'application/pdf' ) |
|
245 |
"/ ) triplesDo:[:suffix :default :mime| |
|
246 |
"/ |cmd| |
|
247 |
"/ |
|
248 |
"/ cmd := Win32OperatingSystem::RegistryEntry executableForSuffix:suffix. |
|
249 |
"/ cmd isNil ifTrue:[ |
|
250 |
"/ "assume its in the path" |
|
251 |
"/ cmd := default. |
|
252 |
"/ ]. |
|
253 |
"/ win32Commands at:mime put:cmd. |
|
254 |
"/ ]. |
|
255 |
"/ ]. |
|
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
256 |
|
1729 | 257 |
" |
258 |
self initializeDefaultCommands |
|
259 |
" |
|
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
260 |
|
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
261 |
"Modified: / 12-05-2004 / 11:43:23 / cg" |
1729 | 262 |
! |
263 |
||
264 |
initializeFileNameToMimeTypeMapping |
|
265 |
"initialize wellKnown facts" |
|
266 |
||
267 |
|types| |
|
268 |
||
269 |
FileSuffixToTypeMapping isNil ifTrue:[ |
|
270 |
FileSuffixToTypeMapping := Dictionary new |
|
271 |
]. |
|
1887 | 272 |
TypeToFileSuffixMapping isNil ifTrue:[ |
273 |
TypeToFileSuffixMapping := Dictionary new |
|
274 |
]. |
|
1729 | 275 |
FilenameToTypeMapping isNil ifTrue:[ |
276 |
FilenameToTypeMapping := Dictionary new. |
|
277 |
]. |
|
278 |
||
279 |
types := OrderedCollection new. |
|
280 |
types addAll:self textTypeList. |
|
281 |
types addAll:self imageTypeList. |
|
282 |
types addAll:self videoTypeList. |
|
283 |
types addAll:self audioTypeList. |
|
284 |
types addAll:self applicationTypeList. |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
285 |
types addAll:self osSpecificTypeList. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
286 |
|
1729 | 287 |
types pairWiseDo:[:suff :typeString| |
288 |
|type| |
|
289 |
||
290 |
type := MIMEType fromString:typeString. |
|
291 |
suff isArray ifTrue:[ |
|
1887 | 292 |
suff do:[:s | FileSuffixToTypeMapping at:s put:type]. |
293 |
TypeToFileSuffixMapping at:type put:suff first. |
|
1729 | 294 |
] ifFalse:[ |
1887 | 295 |
FileSuffixToTypeMapping at:suff put:type. |
296 |
TypeToFileSuffixMapping at:type put:suff. |
|
297 |
]. |
|
1729 | 298 |
]. |
299 |
||
300 |
self miscFilenameList pairWiseDo:[:nm :typeString| |
|
301 |
|type| |
|
302 |
||
303 |
type := MIMEType fromString:typeString. |
|
304 |
nm isArray ifTrue:[ |
|
305 |
nm do:[:s | FilenameToTypeMapping at:s put:type] |
|
306 |
] ifFalse:[ |
|
307 |
FilenameToTypeMapping at:nm put:type |
|
308 |
] |
|
309 |
]. |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
310 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
311 |
" |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
312 |
self initializeFileNameToMimeTypeMapping |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
313 |
" |
1729 | 314 |
! |
315 |
||
316 |
initializeImageReaderMappings |
|
317 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
|
318 |
FileSuffixToImageReaderClassMapping := Dictionary new |
|
319 |
]. |
|
320 |
"MIME" TypeToImageReaderClassMapping isNil ifTrue:[ |
|
321 |
TypeToImageReaderClassMapping := Dictionary new |
|
322 |
]. |
|
323 |
||
324 |
"/ setup mimeType to image reader class mapping ... |
|
325 |
||
326 |
TypeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader. |
|
327 |
TypeToImageReaderClassMapping at:'image/gif' put:GIFReader. |
|
328 |
TypeToImageReaderClassMapping at:'image/tiff' put:TIFFReader. |
|
329 |
||
330 |
"/ setup suffix to image reader class mapping ... |
|
331 |
||
332 |
FileSuffixToImageReaderClassMapping at:'jpg' put:JPEGReader. |
|
333 |
FileSuffixToImageReaderClassMapping at:'gif' put:GIFReader. |
|
334 |
FileSuffixToImageReaderClassMapping at:'tif' put:TIFFReader. |
|
2298 | 335 |
! |
336 |
||
337 |
initializeParentesisSpecMappings |
|
338 |
|spec| |
|
339 |
||
340 |
TypeToParentesisSpecMapping := Dictionary new. |
|
341 |
SuffixToParentesisSpecMapping := Dictionary new. |
|
342 |
||
343 |
"/ ST/X spec |
|
344 |
spec := IdentityDictionary new. |
|
345 |
spec at:#open put:#( $( $[ ${ "$> $<") . |
|
346 |
spec at:#close put:#( $) $] $} "$> $<"). |
|
347 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
|
348 |
spec at:#eolComment put:'"/'. |
|
349 |
||
350 |
TypeToParentesisSpecMapping |
|
351 |
at:'application/x-smalltalk-source' |
|
352 |
put:spec. |
|
353 |
||
2479 | 354 |
"/ XML & HTML |
2298 | 355 |
spec := IdentityDictionary new. |
356 |
spec at:#open put:#( $< ) . |
|
2479 | 357 |
spec at:#close put:#( $> ). |
2298 | 358 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
359 |
||
360 |
#('text/html' 'text/xml' 'application/xml') |
|
361 |
do:[:eachXMLType | |
|
362 |
TypeToParentesisSpecMapping |
|
363 |
at:eachXMLType |
|
364 |
put:spec |
|
365 |
]. |
|
366 |
||
2479 | 367 |
"/ ANSI-c, Java, C# |
2298 | 368 |
spec := IdentityDictionary new. |
369 |
spec at:#open put:#( $( $[ ${ ) . |
|
370 |
spec at:#close put:#( $) $] $} ). |
|
371 |
spec at:#ignore put:#( $' $" ). |
|
372 |
spec at:#eolComment put:'//'. |
|
373 |
||
374 |
TypeToParentesisSpecMapping |
|
375 |
at:'application/x-c-source' |
|
376 |
put:spec. |
|
377 |
||
378 |
TypeToParentesisSpecMapping |
|
379 |
at:'application/x-cpp-source' |
|
380 |
put:spec. |
|
381 |
||
382 |
TypeToParentesisSpecMapping |
|
2479 | 383 |
at:'application/x-csharp-source' |
384 |
put:spec. |
|
385 |
||
386 |
TypeToParentesisSpecMapping |
|
2298 | 387 |
at:'application/x-java-source' |
388 |
put:spec. |
|
389 |
||
390 |
TypeToParentesisSpecMapping |
|
391 |
at:'application/x-javascript' |
|
392 |
put:spec. |
|
393 |
||
394 |
"/ Lisp |
|
395 |
spec := IdentityDictionary new. |
|
396 |
spec at:#open put:#( $( ) . |
|
397 |
spec at:#close put:#( $) ). |
|
398 |
spec at:#ignore put:#( $" ). |
|
399 |
spec at:#eolComment put:';'. |
|
400 |
||
401 |
TypeToParentesisSpecMapping |
|
402 |
at:'application/x-lisp-source' |
|
403 |
put:spec. |
|
404 |
||
405 |
"Created: / 10-04-2007 / 15:16:37 / cg" |
|
1729 | 406 |
! ! |
407 |
||
408 |
!MIMETypes class methodsFor:'initialization-lists'! |
|
409 |
||
410 |
applicationCompressorsAndArchiveTypeList |
|
1604 | 411 |
^ #( |
1890 | 412 |
'tar' 'application/x-tar' |
413 |
'gtar' 'application/x-gtar' |
|
1891 | 414 |
('tgz' 'tar.gz') 'application/x-tar-gzip-compressed' "/ 'application/x-tar-compressed' |
415 |
('tar.bz2') 'application/x-tar-bzip2-compressed' |
|
1890 | 416 |
'zip' 'application/x-zip-compressed' |
417 |
'bz2' 'application/x-bzip2-compressed' |
|
418 |
('gz' 'z') 'application/x-gzip-compressed' |
|
419 |
'cpio' 'application/x-cpio' |
|
420 |
'shar' 'application/x-shar' |
|
421 |
'jar' 'application/java-archive' |
|
422 |
'sar' 'application/x-squeak-archive' |
|
423 |
'sit' 'application/x-stuffit' |
|
424 |
'hqx' 'application/mac-binhex40' |
|
425 |
'cpt' 'application/mac-compactpro' |
|
1604 | 426 |
) |
427 |
! |
|
645 | 428 |
|
1609 | 429 |
applicationMiscTypeList |
430 |
"misc applications" |
|
431 |
||
432 |
^ #( |
|
433 |
('a' 'o' 'obj' ) 'application/binary' |
|
434 |
'a' 'application/library' |
|
435 |
('dll' 'so') 'application/shared-library' |
|
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
436 |
|
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
437 |
('ets') 'application/x-expecco-testsuite' |
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
438 |
('elf') 'application/x-expecco-logfile' |
1609 | 439 |
) |
440 |
! |
|
441 |
||
1604 | 442 |
applicationProgLangTypeList |
1606 | 443 |
"applications for programm languages" |
713 | 444 |
|
1604 | 445 |
^ #( |
1609 | 446 |
('st' 'cls' 'rc') 'application/x-smalltalk-source' |
1604 | 447 |
'sif' 'application/x-smalltalk-source-sif' |
1668 | 448 |
'pac' 'application/x-smalltalk-dolphin-package' |
1778 | 449 |
|
450 |
'sts' 'application/x-squeak-source' |
|
451 |
'pr' 'application/x-squeak-project' |
|
452 |
||
1604 | 453 |
'c' 'application/x-c-source' |
454 |
('cc' 'cpp') 'application/x-cpp-source' |
|
2479 | 455 |
'cs' 'application/x-csharp-source' |
1609 | 456 |
('h' 'hi') 'application/x-c-header' |
1604 | 457 |
('js' 'mocha') 'application/x-javascript' |
458 |
('java' 'jav') 'application/x-java-source' |
|
459 |
'sh' 'application/x-sh' |
|
460 |
'csh' 'application/x-csh' |
|
461 |
'tcl' 'application/x-tcl' |
|
462 |
'pl' 'application/x-perl' |
|
463 |
'mak' 'application/x-make' |
|
464 |
'bat' 'application/x-batch-script' |
|
465 |
('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source' |
|
2298 | 466 |
('lisp' 'lsp' 'scm' 'ss') 'application/x-lisp-source' |
1604 | 467 |
) |
2298 | 468 |
|
469 |
"Modified: / 09-04-2007 / 09:46:04 / cg" |
|
1604 | 470 |
! |
1561 | 471 |
|
1604 | 472 |
applicationTextTypeList |
1606 | 473 |
"text applications" |
1604 | 474 |
|
475 |
^ #( |
|
476 |
('ps' 'eps') 'application/postscript' |
|
1778 | 477 |
"/ 'ai' 'application/postscript' |
1604 | 478 |
'pdf' 'application/pdf' |
479 |
'rtf' 'application/rtf' |
|
1778 | 480 |
"/ 'rtf' 'text/rtf' ???? |
481 |
"/ 'doc' 'application/winword' |
|
1779 | 482 |
'doc' 'application/ms-word-document' |
1778 | 483 |
'swf' 'application/x-shockwave-flash' |
484 |
('ppt' 'ppz' 'pot' 'pps') 'application/mspowerpoint' |
|
2028 | 485 |
'xls' 'application/x-excel' |
486 |
'slk' 'application/vnd.ms-excel' |
|
1604 | 487 |
) |
488 |
! |
|
489 |
||
490 |
applicationTypeList |
|
1606 | 491 |
"applications" |
1604 | 492 |
|
1729 | 493 |
|typeList| |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
494 |
|
1729 | 495 |
typeList := OrderedCollection new. |
496 |
typeList addAll:self applicationProgLangTypeList. |
|
497 |
typeList addAll:self applicationTextTypeList. |
|
498 |
typeList addAll:self applicationCompressorsAndArchiveTypeList. |
|
499 |
typeList addAll:self applicationMiscTypeList. |
|
1616 | 500 |
|
1729 | 501 |
^ typeList |
1604 | 502 |
! |
503 |
||
504 |
audioTypeList |
|
1606 | 505 |
"audio formats ..." |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
506 |
|
1604 | 507 |
^ #( |
1720 | 508 |
('au' 'snd') 'audio/basic' |
1778 | 509 |
('ra') 'audio/x-realaudio' |
510 |
('ram' 'rm') 'audio/x-pn-realaudio' |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
511 |
"/ cg: see unixSpecific / windowsSpecific |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
512 |
"/ 'rpm' 'audio/x-pn-realaudio-plugin' |
1720 | 513 |
('mpa' 'mpega') 'audio/mpeg' |
1778 | 514 |
"/ 'mp3' 'audio/x-mp3' |
515 |
('mp3' 'mp2') 'audio/mpeg' |
|
1604 | 516 |
'wav' 'audio/x-wav' |
517 |
('aif' 'aiff' 'aifc') 'audio/x-aiff' |
|
1778 | 518 |
('midi' 'mid') 'audio/midi' |
1604 | 519 |
) |
520 |
! |
|
521 |
||
522 |
imageTypeList |
|
523 |
||
524 |
^ #( |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
525 |
"/ image formats ... |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
526 |
|
1216 | 527 |
('jpg' 'jpeg') 'image/jpeg' |
1188 | 528 |
'gif' 'image/gif' |
529 |
('tif' 'tiff') 'image/tiff' |
|
530 |
'xbm' 'image/x-xbitmap' |
|
531 |
'xpm' 'image/x-xpixmap' |
|
1720 | 532 |
'png' 'image/png' |
1188 | 533 |
'pcd' 'image/x-photo-cd' |
534 |
'bmp' 'image/x-MS-bmp' |
|
535 |
'rgb' 'image/x-rgb' |
|
536 |
'ppm' 'image/x-portable-pixmap' |
|
537 |
'pgm' 'image/x-portable-graymap' |
|
538 |
'pbm' 'image/x-portable-bitmap' |
|
539 |
'pnm' 'image/x-portable-anymap' |
|
540 |
'xwd' 'image/x-xwindowdump' |
|
541 |
'ras' 'image/x-cmu-raster' |
|
1216 | 542 |
'tga' 'image/x-targa' |
2020 | 543 |
'ico' 'image/x-ico' |
1604 | 544 |
) |
545 |
! |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
546 |
|
1609 | 547 |
miscFilenameList |
548 |
"other formats (not by suffix, but by fileName isnstead) ..." |
|
549 |
||
550 |
^ #( |
|
2113 | 551 |
('makefile' 'make.proto' 'make.spec' 'nt.mak') 'application/x-make' |
552 |
('exe' 'bin') 'application/octet-stream' |
|
553 |
('class') 'application/octet-stream' |
|
2375 | 554 |
('top') 'application/x-waltop-digital-notepad' |
1609 | 555 |
) |
556 |
! |
|
557 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
558 |
osSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
559 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
560 |
^ self windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
561 |
]. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
562 |
^ self unixSpecificTypeList |
2023 | 563 |
|
564 |
" |
|
565 |
self osSpecificTypeList |
|
566 |
" |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
567 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
568 |
|
1604 | 569 |
textTypeList |
570 |
"/ misc text ... |
|
571 |
||
572 |
^ #( |
|
1887 | 573 |
('html' 'htm' 'shtml') 'text/html' |
1604 | 574 |
('txt' 'text') 'text/plain' |
1680 | 575 |
'xml' 'text/xml' |
1777 | 576 |
'css' 'text/css' |
2432 | 577 |
'csv' 'text/csv' |
1604 | 578 |
) |
579 |
! |
|
580 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
581 |
unixSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
582 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
583 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
584 |
"/ cg: RPM is 'audio/x-pn-realaudio-plugin' for WIN32 |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
585 |
"/ and 'application/x-rpm' for Unix |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
586 |
'rpm' 'application/x-rpm' |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
587 |
) |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
588 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
589 |
|
1604 | 590 |
videoTypeList |
591 |
"/ video formats ... |
|
592 |
||
593 |
^ #( |
|
1720 | 594 |
('qt' 'mov' 'moov') 'video/quicktime' |
595 |
('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg' |
|
1604 | 596 |
'movie' 'video/x-sgi-movie' |
1820 | 597 |
('avi' 'wmv' 'asf') 'video/x-msvideo' |
1604 | 598 |
('mpv2' 'mp2v' 'mp2' 'mpeg2') 'video/x-mpeg2' |
1680 | 599 |
'rm' 'application/vnd.rn-realmedia' |
600 |
'rv' 'video/x-pn-realvideo' |
|
1778 | 601 |
) |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
602 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
603 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
604 |
windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
605 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
606 |
"/ cg: RPM is 'audio/x-pn-realaudio-plugin' for WIN32 |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
607 |
"/ and 'application/x-rpm' for Unix |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
608 |
'rpm' 'audio/x-pn-realaudio-plugin' |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
609 |
) |
643 | 610 |
! ! |
611 |
||
1729 | 612 |
!MIMETypes class methodsFor:'obsolete'! |
1489 | 613 |
|
1729 | 614 |
fontForCharset:aCharSetName |
615 |
"return the font-encoding for an iso-charset" |
|
1489 | 616 |
|
1981 | 617 |
<resource:#obsolete> |
1729 | 618 |
self obsoleteMethodWarning:'use FontDescription >> fontNamePatternForCharset:'. |
619 |
^ FontDescription fontNamePatternForCharset:aCharSetName. |
|
1489 | 620 |
|
621 |
" |
|
1729 | 622 |
MIMETypes fontForCharset:'iso2022-jp' |
623 |
MIMETypes fontForCharset:'euc-jp' |
|
1472 | 624 |
" |
625 |
||
1729 | 626 |
"Modified: / 1.8.1998 / 17:00:57 / cg" |
627 |
! ! |
|
1472 | 628 |
|
1729 | 629 |
!MIMETypes class methodsFor:'queries'! |
1472 | 630 |
|
647 | 631 |
defineImageType:mimeType suffix:aSuffix reader:aReaderClass |
632 |
"register an image reader." |
|
633 |
||
634 |
aSuffix notNil ifTrue:[ |
|
635 |
self imageReaderForSuffix:aSuffix put:aReaderClass. |
|
636 |
]. |
|
637 |
||
638 |
mimeType notNil ifTrue:[ |
|
639 |
self imageReaderForType:mimeType put:aReaderClass |
|
640 |
]. |
|
641 |
||
642 |
(aSuffix notNil and:[mimeType notNil]) ifTrue:[ |
|
643 |
self mimeTypeForSuffix:aSuffix put:mimeType |
|
644 |
]. |
|
645 |
! |
|
646 |
||
643 | 647 |
fileSuffixToImageReaderMapping |
1021 | 648 |
"return the suffix-to-imageReader mapping" |
649 |
||
643 | 650 |
^ FileSuffixToImageReaderClassMapping ? #() |
651 |
||
1021 | 652 |
"Modified: / 1.8.1998 / 17:00:11 / cg" |
643 | 653 |
! |
654 |
||
655 |
imageFileSuffixes |
|
1021 | 656 |
"return a collection with known file suffixes" |
657 |
||
643 | 658 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()]. |
659 |
^ FileSuffixToImageReaderClassMapping keys |
|
660 |
||
1021 | 661 |
"Created: / 30.6.1997 / 22:04:48 / cg" |
662 |
"Modified: / 1.8.1998 / 17:01:26 / cg" |
|
643 | 663 |
! |
664 |
||
1473 | 665 |
mimeTypeForFilename:filenameArg |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
666 |
"given a filename, return the mime-type or nil, if unknown" |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
667 |
|
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
668 |
|type filename lcFilename suff suff2| |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
669 |
|
1473 | 670 |
filename := filenameArg asFilename. |
1474 | 671 |
|
672 |
lcFilename := filename baseName asLowercase. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
673 |
type := FilenameToTypeMapping at:lcFilename ifAbsent:nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
674 |
type isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
675 |
"/ allow for fallback ... |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
676 |
type := OperatingSystem mimeTypeForFilename:lcFilename. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
677 |
"/ the special value #unknown is returned as nil; |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
678 |
"/ this avoids constant retry if a mimeType is not known in |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
679 |
"/ the OS. |
1275 | 680 |
"/ type isNil ifTrue:[ |
681 |
"/ FilenameToTypeMapping at:lcFilename put:#unknown |
|
682 |
"/ ]. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
683 |
]. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
684 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
685 |
type == #unknown ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
686 |
type := nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
687 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
688 |
|
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
689 |
type isNil ifTrue:[ |
1473 | 690 |
suff := filename suffix. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
691 |
suff size ~~ 0 ifTrue:[ |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
692 |
"/ sigh - special code for multiple-suffices... |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
693 |
"/ .tar.gz -> tgz |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
694 |
suff2 := filename withoutSuffix suffix. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
695 |
suff2 size > 0 ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
696 |
type := self mimeTypeForSuffix:(suff2 , '.' , suff). |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
697 |
]. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
698 |
type isNil ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
699 |
type := self mimeTypeForSuffix:suff |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
700 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
701 |
] |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
702 |
]. |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
703 |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
704 |
^ type |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
705 |
|
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
706 |
" |
1841 | 707 |
self mimeTypeForFilename:'typeinst.dvi' |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
708 |
self mimeTypeForFilename:'foo.tar' |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
709 |
self mimeTypeForFilename:'foo.tgz' |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
710 |
self mimeTypeForFilename:'foo.tar.gz' |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
711 |
" |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
712 |
! |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
713 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
714 |
mimeTypeForFilename:filename put:mimeType |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
715 |
"register a mime type for a filename" |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
716 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
717 |
FilenameToTypeMapping isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
718 |
FilenameToTypeMapping := Dictionary new |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
719 |
]. |
1612 | 720 |
FilenameToTypeMapping at:filename put:(MIMEType fromString:mimeType asLowercase) |
1611 | 721 |
! |
722 |
||
643 | 723 |
mimeTypeForSuffix:suffix |
1021 | 724 |
"given a file suffix, return the mime-type" |
725 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
726 |
|type lcSuffix| |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
727 |
|
1837 | 728 |
suffix = LastSuffix ifTrue:[ |
729 |
^ LastType |
|
730 |
]. |
|
731 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
732 |
lcSuffix := suffix asLowercase. |
1837 | 733 |
type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil. |
734 |
type isNil ifTrue:[ |
|
735 |
"/ allow for fallback ... |
|
736 |
type := OperatingSystem mimeTypeForSuffix:lcSuffix. |
|
737 |
"/ the special value #unknown is returned as nil; |
|
738 |
"/ this avoids constant retry if a mimeType is not known in the OS. |
|
739 |
||
740 |
type := type ? #unknown. |
|
741 |
FileSuffixToTypeMapping at:lcSuffix put:type. |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
742 |
]. |
1837 | 743 |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
744 |
type == #unknown ifTrue:[ |
1837 | 745 |
type := nil. |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
746 |
]. |
1840 | 747 |
type notNil ifTrue:[ |
748 |
LastSuffix := suffix. |
|
749 |
LastType := MIMEType fromString:type. |
|
750 |
^ LastType |
|
751 |
]. |
|
1841 | 752 |
^ type |
643 | 753 |
|
1666 | 754 |
" |
1840 | 755 |
self mimeTypeForSuffix:'gif' |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
756 |
self mimeTypeForSuffix:'rpm' |
1666 | 757 |
" |
758 |
||
1021 | 759 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
1300 | 760 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
643 | 761 |
! |
762 |
||
763 |
mimeTypeForSuffix:suffix put:mimeType |
|
1021 | 764 |
"register a mime type for a file suffix" |
765 |
||
643 | 766 |
FileSuffixToTypeMapping isNil ifTrue:[ |
767 |
FileSuffixToTypeMapping := Dictionary new |
|
768 |
]. |
|
769 |
FileSuffixToTypeMapping at:suffix put:mimeType asLowercase |
|
770 |
||
1021 | 771 |
"Created: / 30.6.1997 / 21:56:20 / cg" |
772 |
"Modified: / 1.8.1998 / 17:03:18 / cg" |
|
1593 | 773 |
! |
774 |
||
775 |
mimeTypeForSuffixMapping |
|
776 |
||
777 |
^ FileSuffixToTypeMapping |
|
1611 | 778 |
! |
779 |
||
2023 | 780 |
mimeTypeFromString:mimeTypeString |
781 |
"given a mime-type for a string" |
|
782 |
||
783 |
^ MIMEType fromString:mimeTypeString |
|
784 |
||
785 |
" |
|
786 |
self mimeTypeFromString:'image/gif' |
|
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
787 |
self mimeTypeFromString:'application/x-expecco-testsuite' |
2023 | 788 |
" |
789 |
! |
|
790 |
||
1611 | 791 |
mimeTypeOfContents:filename |
792 |
"given a filename, scan the contents, return the mime-type or nil, if unknown" |
|
793 |
||
1612 | 794 |
|typeString| |
795 |
||
796 |
typeString := filename mimeTypeOfContents. |
|
797 |
typeString isNil ifTrue:[^ nil]. |
|
798 |
^ MIMEType fromString:typeString. |
|
1887 | 799 |
! |
800 |
||
801 |
suffixForMimeType:mimeType |
|
802 |
"given a file suffix, return the mime-type" |
|
803 |
||
804 |
^ TypeToFileSuffixMapping at:mimeType ifAbsent:nil |
|
805 |
||
806 |
" |
|
807 |
self suffixForMimeType:(MIMEType fromString:'image/gif') |
|
808 |
" |
|
809 |
||
810 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
811 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
812 |
! |
|
813 |
||
814 |
suffixForMimeTypeString:mimeTypeString |
|
815 |
"given a file suffix, return the mime-type" |
|
816 |
||
817 |
^ self suffixForMimeType:(MIMEType fromString:mimeTypeString) |
|
818 |
||
819 |
" |
|
820 |
self suffixForMimeTypeString:'image/gif' |
|
821 |
" |
|
822 |
||
823 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
824 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
1612 | 825 |
! ! |
826 |
||
2116 | 827 |
!MIMETypes class methodsFor:'queries-applications'! |
828 |
||
2117 | 829 |
defaultCommandForMimeType:mimeType |
830 |
self obsoleteMethodWarning:'use #defaultCommandTemplateToOpenMimeType:'. |
|
831 |
||
832 |
^ self defaultCommandTemplateToOpenMimeType:mimeType |
|
833 |
||
834 |
" |
|
835 |
MIMETypes defaultCommandForMimeType:'application/pdf' |
|
836 |
" |
|
837 |
||
838 |
"Created: / 12-05-2004 / 11:09:22 / cg" |
|
839 |
"Modified: / 12-05-2004 / 11:16:53 / cg" |
|
840 |
! |
|
841 |
||
842 |
defaultCommandPerMIME |
|
843 |
"returns the collection which is used to map MIME-type to command-templates." |
|
844 |
||
845 |
"TODO: move this to OS/UserPreferences" |
|
846 |
||
847 |
DefaultCommandPerMIMEPerOS isNil ifTrue:[ |
|
848 |
self initializeDefaultCommands |
|
849 |
]. |
|
850 |
OperatingSystem isUNIXlike ifTrue:[ |
|
851 |
^ DefaultCommandPerMIMEPerOS at:#unix |
|
852 |
]. |
|
853 |
^ DefaultCommandPerMIMEPerOS at:#win32 |
|
854 |
! |
|
855 |
||
2116 | 856 |
defaultCommandTemplateToOpenMimeType:mimeType |
857 |
|cmd| |
|
858 |
||
859 |
cmd := self defaultCommandPerMIME at:mimeType ifAbsent:nil. |
|
860 |
cmd isNil ifTrue:[ |
|
861 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
862 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:mimeType |
|
863 |
]. |
|
864 |
]. |
|
865 |
^ cmd |
|
866 |
||
867 |
" |
|
868 |
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf' |
|
2118 | 869 |
MIMETypes defaultCommandTemplateToOpenMimeType:'text/html' |
2116 | 870 |
" |
871 |
||
872 |
"Created: / 12-05-2004 / 11:09:22 / cg" |
|
873 |
"Modified: / 12-05-2004 / 11:16:53 / cg" |
|
874 |
! |
|
875 |
||
876 |
defaultCommandTemplateToPrintMimeType:mimeType |
|
877 |
|cmd| |
|
878 |
||
879 |
cmd := self defaultPrintCommandPerMIME at:mimeType ifAbsent:nil. |
|
880 |
cmd isNil ifTrue:[ |
|
881 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
882 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToPrintMimeType:mimeType |
|
883 |
]. |
|
884 |
]. |
|
885 |
^ cmd |
|
886 |
||
887 |
" |
|
888 |
MIMETypes defaultCommandTemplateToPrintMimeType:'application/pdf' |
|
889 |
" |
|
2117 | 890 |
! |
891 |
||
892 |
defaultPrintCommandPerMIME |
|
893 |
"returns the collection which is used to map MIME-type to printing command-templates." |
|
894 |
||
895 |
"TODO: move this to OS/UserPreferences" |
|
896 |
||
897 |
DefaultPrintCommandPerMIMEPerOS isNil ifTrue:[ |
|
898 |
self initializeDefaultCommands |
|
899 |
]. |
|
900 |
OperatingSystem isUNIXlike ifTrue:[ |
|
901 |
^ DefaultPrintCommandPerMIMEPerOS at:#unix |
|
902 |
]. |
|
903 |
^ DefaultPrintCommandPerMIMEPerOS at:#win32 |
|
2116 | 904 |
! ! |
905 |
||
1729 | 906 |
!MIMETypes class methodsFor:'queries-image formats'! |
907 |
||
908 |
imageReaderClasses |
|
909 |
"return a collection of registered image reader classes" |
|
910 |
||
911 |
|setOfClasses| |
|
912 |
||
913 |
setOfClasses := IdentitySet new. |
|
914 |
FileSuffixToImageReaderClassMapping notNil ifTrue:[ |
|
915 |
FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
916 |
setOfClasses add:cls |
|
917 |
]. |
|
918 |
]. |
|
919 |
TypeToImageReaderClassMapping notNil ifTrue:[ |
|
920 |
TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
921 |
setOfClasses add:cls |
|
922 |
]. |
|
923 |
]. |
|
924 |
^ setOfClasses |
|
925 |
||
926 |
"Created: / 30.6.1997 / 22:03:42 / cg" |
|
927 |
"Modified: / 1.8.1998 / 16:59:52 / cg" |
|
928 |
! |
|
929 |
||
930 |
imageReaderForSuffix:aSuffix |
|
931 |
"given a file suffix, return an approriate image reader class" |
|
932 |
||
933 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil]. |
|
934 |
^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil |
|
935 |
||
936 |
"Created: / 30.6.1997 / 21:59:11 / cg" |
|
937 |
"Modified: / 1.8.1998 / 17:01:58 / cg" |
|
938 |
! |
|
939 |
||
940 |
imageReaderForSuffix:aSuffix put:aReaderClass |
|
941 |
"register an image reader for a file suffix" |
|
942 |
||
943 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
|
944 |
FileSuffixToImageReaderClassMapping := Dictionary new. |
|
945 |
]. |
|
946 |
FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass |
|
947 |
||
948 |
"Created: / 30.6.1997 / 21:59:43 / cg" |
|
949 |
"Modified: / 1.8.1998 / 17:02:14 / cg" |
|
950 |
! |
|
951 |
||
952 |
imageReaderForType:mimeTypeString |
|
953 |
"given a mime-type, return an approriate image reader class" |
|
954 |
||
955 |
TypeToImageReaderClassMapping isNil ifTrue:[^ nil]. |
|
956 |
^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil |
|
957 |
||
958 |
"Created: / 30.6.1997 / 21:56:01 / cg" |
|
959 |
"Modified: / 1.8.1998 / 17:02:28 / cg" |
|
960 |
! |
|
961 |
||
962 |
imageReaderForType:mimeTypeString put:aReaderClass |
|
963 |
"register an image reader for a mime-type" |
|
964 |
||
965 |
TypeToImageReaderClassMapping isNil ifTrue:[ |
|
966 |
TypeToImageReaderClassMapping := Dictionary new. |
|
967 |
]. |
|
968 |
TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass |
|
969 |
||
970 |
"Created: / 30.6.1997 / 21:56:11 / cg" |
|
971 |
"Modified: / 1.8.1998 / 17:02:40 / cg" |
|
972 |
! ! |
|
973 |
||
974 |
!MIMETypes class methodsFor:'queries-language syntax'! |
|
975 |
||
976 |
commentStringsForFilename:aFilename |
|
977 |
"return a useful comment definition; heuristics for now. |
|
978 |
The returned value is an array of 2 elements; |
|
979 |
the first is the end-of-line comment string (or nil); |
|
980 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
981 |
||
982 |
|mime| |
|
983 |
||
984 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
985 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) |
|
986 |
||
987 |
" |
|
988 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
989 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
990 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1925 | 991 |
MIMETypes commentStringsForFilename:'Foo.html'. |
1729 | 992 |
" |
993 |
! |
|
994 |
||
995 |
commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString |
|
996 |
"return a useful comment definition; heuristics for now. |
|
997 |
The returned value is an array of 2 elements; |
|
998 |
the first is the end-of-line comment string (or nil); |
|
999 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1000 |
||
1001 |
|mime| |
|
1002 |
||
1003 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1004 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString |
|
1005 |
||
1006 |
" |
|
1007 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1008 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1009 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1010 |
" |
|
1011 |
! |
|
1012 |
||
1013 |
commentStringsForMimeType:mime suffix:suff |
|
1014 |
"return a useful comment definition; heuristics for now. |
|
1015 |
The returned value is an array of 2 elements; |
|
1016 |
the first is the end-of-line comment string (or nil); |
|
1017 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1018 |
||
1019 |
^ self |
|
1020 |
commentStringsForMimeType:mime suffix:suff |
|
1021 |
ifUnknown: #(';' (nil nil)) |
|
1022 |
||
1023 |
" |
|
1024 |
|mime| |
|
1025 |
||
1026 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1027 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1028 |
" |
|
1029 |
||
1030 |
" |
|
1031 |
|mime| |
|
1032 |
||
1033 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1034 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1035 |
" |
|
1036 |
! |
|
1037 |
||
1038 |
commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString |
|
1039 |
"return a useful comment definition; heuristics for now. |
|
1040 |
The returned value is an array of 2 elements; |
|
1041 |
the first is the end-of-line comment string (or nil); |
|
1042 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1043 |
||
1044 |
|commentSpec| |
|
1045 |
||
1046 |
commentSpec := TypeToCommentStringMapping at:mime ifAbsent:nil. |
|
1047 |
commentSpec notNil ifTrue:[ |
|
1048 |
^ commentSpec |
|
1049 |
]. |
|
1050 |
||
1051 |
commentSpec := SuffixToCommentStringMapping at:suff ifAbsent:nil. |
|
1052 |
commentSpec notNil ifTrue:[ |
|
1053 |
^ commentSpec |
|
1054 |
]. |
|
1055 |
||
1056 |
^ alternativeBlockReturningCommentString value |
|
1057 |
||
1058 |
" |
|
1059 |
|mime| |
|
1060 |
||
1061 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1062 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1063 |
" |
|
1064 |
||
1065 |
" |
|
1066 |
|mime| |
|
1067 |
||
1068 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1069 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1070 |
" |
|
2298 | 1071 |
! |
1072 |
||
1073 |
parentesisSpecForFilename:aFilename |
|
1074 |
"return a useful parentesis spec; heuristics for now. |
|
1075 |
The returned value is a dictionary to be used as parentesis spec in an editor" |
|
1076 |
||
1077 |
|mime| |
|
1078 |
||
1079 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1080 |
^ self parentesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) |
|
1081 |
||
1082 |
" |
|
1083 |
MIMETypes parentesisSpecForFilename:'Object.st'. |
|
1084 |
MIMETypes parentesisSpecForFilename:'Foo.java'. |
|
1085 |
MIMETypes parentesisSpecForFilename:'Foo.html'. |
|
1086 |
MIMETypes parentesisSpecForFilename:'Foo.lsp'. |
|
1087 |
" |
|
1088 |
||
1089 |
"Created: / 10-04-2007 / 15:18:41 / cg" |
|
1090 |
! |
|
1091 |
||
1092 |
parentesisSpecForFilename:aFilename ifUnknown:alternative |
|
1093 |
|mime| |
|
1094 |
||
1095 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1096 |
^ self parentesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternative |
|
1097 |
||
1098 |
"Created: / 10-04-2007 / 15:26:20 / cg" |
|
1099 |
! |
|
1100 |
||
1101 |
parentesisSpecForMimeType:mime suffix:suff |
|
1102 |
^ self |
|
1103 |
parentesisSpecForMimeType:mime suffix:suff |
|
1104 |
ifUnknown: nil |
|
1105 |
||
1106 |
"Created: / 10-04-2007 / 15:19:39 / cg" |
|
1107 |
! |
|
1108 |
||
1109 |
parentesisSpecForMimeType:mime suffix:suff ifUnknown:alternativeValue |
|
1110 |
|spec| |
|
1111 |
||
1112 |
spec := TypeToParentesisSpecMapping at:mime ifAbsent:nil. |
|
1113 |
spec notNil ifTrue:[ |
|
1114 |
^ spec |
|
1115 |
]. |
|
1116 |
||
1117 |
spec := SuffixToParentesisSpecMapping at:suff ifAbsent:nil. |
|
1118 |
spec notNil ifTrue:[ |
|
1119 |
^ spec |
|
1120 |
]. |
|
1121 |
||
1122 |
^ alternativeValue value |
|
1123 |
||
1124 |
"Created: / 10-04-2007 / 15:20:38 / cg" |
|
1729 | 1125 |
! ! |
1126 |
||
1612 | 1127 |
!MIMETypes::MIMEType class methodsFor:'documentation'! |
1128 |
||
1129 |
documentation |
|
1130 |
" |
|
1864 | 1131 |
like a string, but knows that it represents a mimeType. |
1612 | 1132 |
" |
1133 |
! ! |
|
1134 |
||
1135 |
!MIMETypes::MIMEType class methodsFor:'initialization'! |
|
1136 |
||
1137 |
initialize |
|
1138 |
CachedTypes := CacheDictionary new:30. |
|
1139 |
||
1140 |
" |
|
1141 |
self initialize |
|
1142 |
" |
|
1143 |
! ! |
|
1144 |
||
1145 |
!MIMETypes::MIMEType class methodsFor:'instance creation'! |
|
1146 |
||
1147 |
fromString:aString |
|
1148 |
|cachedType newType| |
|
1149 |
||
1150 |
aString class == self ifTrue:[^ aString]. |
|
1151 |
||
1152 |
cachedType := CachedTypes at:aString ifAbsent:nil. |
|
1153 |
cachedType notNil ifTrue:[^ cachedType]. |
|
1154 |
newType := aString copy changeClassTo:self. |
|
1155 |
CachedTypes at:aString put:newType. |
|
1156 |
^ newType |
|
1157 |
||
1158 |
" |
|
1159 |
self fromString:'text/html' |
|
1160 |
" |
|
1161 |
! ! |
|
1162 |
||
1163 |
!MIMETypes::MIMEType methodsFor:'queries'! |
|
1164 |
||
1693 | 1165 |
isArchive |
1864 | 1166 |
"return true, if I represent an archive type (such as zip or tar)" |
1167 |
||
1612 | 1168 |
|archivTypes| |
1169 |
||
1729 | 1170 |
archivTypes := MIMETypes applicationCompressorsAndArchiveTypeList. |
1612 | 1171 |
archivTypes pairWiseDo:[: ext : type | |
1172 |
self = type ifTrue:[ ^ true]. |
|
1173 |
]. |
|
1174 |
^ false |
|
1175 |
! |
|
1176 |
||
2024 | 1177 |
isBinary |
1178 |
"return true, if I represent a binary (non-text) type" |
|
1179 |
||
1180 |
^ self isTextType not |
|
1181 |
! |
|
1182 |
||
1612 | 1183 |
isHtml |
1864 | 1184 |
"return true, if I represent the html text type" |
1612 | 1185 |
|
1186 |
^ (self = 'text/html') |
|
1187 |
! |
|
1188 |
||
1189 |
isImage |
|
1864 | 1190 |
"return true, if I represent an image type (such as gif or jpg)" |
1612 | 1191 |
|
1693 | 1192 |
^ (self startsWith:'image/') |
1612 | 1193 |
! |
1194 |
||
1195 |
isPdf |
|
1864 | 1196 |
"return true, if I represent the pdf type" |
1197 |
||
1612 | 1198 |
^ (self = 'application/pdf') |
1199 |
! |
|
1200 |
||
1201 |
isSmalltalkSource |
|
1864 | 1202 |
"return true, if I represent the smalltalk sourcecode type" |
1203 |
||
1612 | 1204 |
^ (self = 'application/x-smalltalk-source') |
1783 | 1205 |
! |
1206 |
||
2024 | 1207 |
isTextType |
1208 |
"return true, if I represent some text type" |
|
1209 |
||
1210 |
^ self startsWith:'text/' |
|
1211 |
! |
|
1212 |
||
1783 | 1213 |
isXml |
1864 | 1214 |
"return true, if I represent the xml text type" |
1215 |
||
1783 | 1216 |
^ (self = 'text/xml') |
643 | 1217 |
! ! |
1218 |
||
1219 |
!MIMETypes class methodsFor:'documentation'! |
|
1220 |
||
1221 |
version |
|
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1222 |
^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.94 2008-06-04 09:06:22 cg Exp $' |
643 | 1223 |
! ! |
1666 | 1224 |
|
643 | 1225 |
MIMETypes initialize! |
1666 | 1226 |
MIMETypes::MIMEType initialize! |