author | Claus Gittinger <cg@exept.de> |
Thu, 10 Jul 2014 21:45:59 +0200 | |
changeset 3359 | 62084f197409 |
parent 3332 | 5ab088e3de36 |
child 3367 | 048fc9f61885 |
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 |
3359 | 22 |
TypeToParenthesisSpecMapping SuffixToParenthesisSpecMapping |
23 |
TypeToInfoMapping' |
|
1612 | 24 |
poolDictionaries:'' |
1800 | 25 |
category:'Net-Communication-Support' |
1612 | 26 |
! |
27 |
||
3359 | 28 |
ImmutableString variableByteSubclass:#MIMEType |
1612 | 29 |
instanceVariableNames:'' |
30 |
classVariableNames:'CachedTypes' |
|
31 |
poolDictionaries:'' |
|
32 |
privateIn:MIMETypes |
|
643 | 33 |
! |
34 |
||
35 |
!MIMETypes class methodsFor:'documentation'! |
|
36 |
||
37 |
copyright |
|
38 |
" |
|
39 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
1612 | 40 |
All Rights Reserved |
643 | 41 |
|
42 |
This software is furnished under a license and may be used |
|
43 |
only in accordance with the terms of that license and with the |
|
44 |
inclusion of the above copyright notice. This software may not |
|
45 |
be provided or otherwise made available to, or used by, any |
|
46 |
other person. No title to or ownership of the software is |
|
47 |
hereby transferred. |
|
48 |
||
49 |
||
50 |
" |
|
51 |
! |
|
52 |
||
53 |
documentation |
|
54 |
" |
|
55 |
just a place to keep MIME information |
|
56 |
(avoid spreading things at many places) |
|
57 |
||
1021 | 58 |
MIMETypes is abstract and functional. |
59 |
Actually, in some OperatingSystems, this information may |
|
60 |
be found in some config files (or registries). |
|
61 |
Therefore, this class may have to be extended to support this |
|
62 |
and fetch the information from there eventually. |
|
63 |
||
643 | 64 |
[author:] |
65 |
Claus Gittinger |
|
66 |
" |
|
1311 | 67 |
! |
68 |
||
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
69 |
examples |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
70 |
" |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
71 |
[exBegin] |
3210 | 72 |
MIMETypes mimeTypeFromString:'text/plain' |
73 |
[exEnd] |
|
74 |
[exBegin] |
|
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
75 |
MIMETypes mimeTypeFromString:'application/x-expecco-testsuite' |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
76 |
[exEnd] |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
77 |
|
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
78 |
[exBegin] |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
79 |
MIMETypes mimeTypeForSuffix:'gif' |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
80 |
MIMETypes mimeTypeForSuffix:'ets' |
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
81 |
MIMETypes mimeTypeForSuffix:'xlsx' |
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
82 |
[exEnd] |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
83 |
" |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
84 |
! |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
85 |
|
1311 | 86 |
knownTypes |
87 |
" |
|
88 |
simply a reminder for me ... |
|
89 |
||
90 |
application mime file extentsions |
|
91 |
||
92 |
powerpoint application/ms-powerpoint .pot, .ppz, .ppt, .pps, |
|
93 |
application/mspowerpoint |
|
94 |
application/vnd.ms-powerpoint |
|
95 |
application/x-mspowerpoint |
|
96 |
||
1312 | 97 |
shockwave application/x-shockwave-flash .swf |
1311 | 98 |
|
1312 | 99 |
futuresplash application/futuresplash .spl |
1311 | 100 |
" |
643 | 101 |
! ! |
102 |
||
103 |
!MIMETypes class methodsFor:'initialization'! |
|
104 |
||
1729 | 105 |
initialize |
106 |
"initialize wellKnown facts" |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
107 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
108 |
MIMEType initialize. "must be initialized first" |
1729 | 109 |
LastSuffix := LastType := nil. |
110 |
self initializeFileNameToMimeTypeMapping. |
|
111 |
self initializeImageReaderMappings. |
|
112 |
self initializeCommentStringMappings. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
113 |
self initializeParenthesisSpecMappings. |
1729 | 114 |
|
115 |
" |
|
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
116 |
self initialize |
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
117 |
" |
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
118 |
|
2298 | 119 |
"Modified: / 10-04-2007 / 15:16:44 / cg" |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
120 |
"Modified (comment): / 29-11-2011 / 19:11:51 / cg" |
1729 | 121 |
! |
122 |
||
123 |
initializeCommentStringMappings |
|
3359 | 124 |
"these are used by the editor's comment/uncomment functions" |
125 |
||
1729 | 126 |
TypeToCommentStringMapping := Dictionary new. |
127 |
SuffixToCommentStringMapping := Dictionary new. |
|
128 |
||
129 |
TypeToCommentStringMapping |
|
130 |
at:'application/x-make' |
|
3359 | 131 |
put:#('#' (nil nil)). "/ '#' EOL comments only |
1729 | 132 |
|
133 |
TypeToCommentStringMapping |
|
134 |
at:'application/x-sh' |
|
3359 | 135 |
put:#('#' (nil nil)). "/ '#' EOL comments only |
1729 | 136 |
|
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
137 |
#('text/html' 'text/xml' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
138 |
'application/xml' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
139 |
'application/x-expecco-testsuite' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
140 |
'application/x-expecco-logfile' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
141 |
) |
1729 | 142 |
do:[:eachXMLType | |
143 |
TypeToCommentStringMapping |
|
144 |
at:eachXMLType |
|
145 |
put:#(nil ('<!!-- ' ' -->')). "/ '<!!-- ... -->' delimited comments only |
|
146 |
]. |
|
147 |
||
148 |
TypeToCommentStringMapping |
|
2055 | 149 |
at:'text/css' |
150 |
put:#('//' ('/*' '*/')). |
|
151 |
||
152 |
TypeToCommentStringMapping |
|
1729 | 153 |
at:'application/x-batch-script' |
2937
67ef44218dc0
changed: #initializeCommentStringMappings
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
154 |
put:#('@REM ' '@rem ' 'REM ' 'rem ' (nil nil)). "/ 'rem ' for EOL comments only |
1729 | 155 |
|
156 |
"/ the following is ST/X specific |
|
157 |
TypeToCommentStringMapping |
|
158 |
at:'application/x-smalltalk-source' |
|
159 |
put:#('"/' ('"' '"')). "/ '"/ ' for EOL; ".." for delimited comments |
|
160 |
||
161 |
"/ this is for standard smalltalk |
|
162 |
"/ TypeToCommentStringMapping |
|
163 |
"/ at:'application/x-smalltalk-source' |
|
164 |
"/ put:#(nil ('"' '"')). "/ ".." for delimited comments only |
|
165 |
||
166 |
||
167 |
TypeToCommentStringMapping |
|
168 |
at:'application/x-pascal-source' |
|
169 |
put:#(nil ('{' '}')). "/ '{'..'}' for delimited comments |
|
170 |
||
171 |
"/ this is ANSI-c |
|
172 |
TypeToCommentStringMapping |
|
173 |
at:'application/x-c-source' |
|
174 |
put:#('//' ('/*' '*/')). |
|
175 |
||
176 |
TypeToCommentStringMapping |
|
177 |
at:'application/x-cpp-source' |
|
178 |
put:#('//' ('/*' '*/')). |
|
179 |
||
180 |
TypeToCommentStringMapping |
|
2479 | 181 |
at:'application/x-csharp-source' |
182 |
put:#('//' ('/*' '*/')). |
|
183 |
||
184 |
TypeToCommentStringMapping |
|
1729 | 185 |
at:'application/x-java-source' |
186 |
put:#('//' ('/*' '*/')). |
|
187 |
||
188 |
TypeToCommentStringMapping |
|
2048
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
189 |
at:'application/x-javascript' |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
190 |
put:#('//' ('/*' '*/')). |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
191 |
|
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
192 |
TypeToCommentStringMapping |
2298 | 193 |
at:'application/x-lisp-source' |
194 |
put:#(';' (nil nil)). "/ '#' for EOL comments only |
|
195 |
||
196 |
TypeToCommentStringMapping |
|
1729 | 197 |
at:'application/x-asn1-source' |
198 |
put:#('--' ('--' '--')). |
|
199 |
||
200 |
||
201 |
"/ st/x support files |
|
202 |
SuffixToCommentStringMapping |
|
203 |
at:'style' |
|
204 |
put:#(';' (nil nil)). |
|
1604 | 205 |
|
1729 | 206 |
SuffixToCommentStringMapping |
207 |
at:'rs' |
|
2298 | 208 |
put:#(';' (nil nil)). |
209 |
||
2937
67ef44218dc0
changed: #initializeCommentStringMappings
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
210 |
"Modified: / 06-09-2011 / 10:46:27 / cg" |
1729 | 211 |
! |
212 |
||
213 |
initializeDefaultCommands |
|
3359 | 214 |
"these are used to select an application to be opened when a file of a particular |
215 |
type is double clicked in the browser. |
|
216 |
TODO: move this to OS" |
|
1729 | 217 |
|
3253 | 218 |
|unixCommands win32Commands unixPrintCommands win32PrintCommands listToTry| |
1729 | 219 |
|
220 |
DefaultCommandPerMIMEPerOS := Dictionary new. |
|
221 |
DefaultCommandPerMIMEPerOS at:#unix put:(unixCommands := Dictionary new). |
|
222 |
DefaultCommandPerMIMEPerOS at:#win32 put:(win32Commands := Dictionary new). |
|
223 |
||
3187 | 224 |
unixCommands at:'application/x-tar-compressed' put:'tar tvf -'. |
1729 | 225 |
|
2141 | 226 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |cmd| |
3253 | 227 |
OperatingSystem isOSXlike ifTrue:[ |
3322 | 228 |
unixCommands at:'text/html' put:('open -a Safari "%1"'). |
229 |
unixCommands at:'application/pdf' put:('open -a Preview "%1"'). |
|
3253 | 230 |
] ifFalse:[ |
3322 | 231 |
listToTry := #('firefox' 'chrome' 'chromium' 'konqueror' 'opera'). |
232 |
cmd := listToTry |
|
233 |
detect:[:aCmd| (OperatingSystem pathOfCommand:aCmd) notEmptyOrNil ] |
|
234 |
ifNone:nil. |
|
235 |
cmd notNil ifTrue:[ |
|
236 |
unixCommands at:'text/html' put:(cmd, ' "%1"') |
|
237 |
]. |
|
3187 | 238 |
|
3322 | 239 |
listToTry := #('acroread' 'okular' 'evince' 'kpdf' 'xpdf'). |
240 |
cmd := listToTry |
|
241 |
detect:[:aCmd| (OperatingSystem pathOfCommand:aCmd) notEmptyOrNil ] |
|
242 |
ifNone:nil. |
|
243 |
cmd notNil ifTrue:[ |
|
244 |
unixCommands at:'application/pdf' put:(cmd, ' "%1"') |
|
245 |
]. |
|
3187 | 246 |
]. |
2141 | 247 |
]. |
248 |
||
249 |
||
2116 | 250 |
DefaultPrintCommandPerMIMEPerOS := Dictionary new. |
251 |
DefaultPrintCommandPerMIMEPerOS at:#unix put:(unixPrintCommands := Dictionary new). |
|
252 |
DefaultPrintCommandPerMIMEPerOS at:#win32 put:(win32PrintCommands := Dictionary new). |
|
253 |
||
254 |
"/ if you have a good (intelligent) spooler ;-) |
|
2904
bb555534881e
changed: #initializeDefaultCommands
Stefan Vogel <sv@exept.de>
parents:
2892
diff
changeset
|
255 |
unixPrintCommands at:'application/pdf' put:'lpr "%1"'. |
2116 | 256 |
"/ if not, you may need more... |
257 |
"/ unixPrintCommands at:'application/pdf' put:'pdfToPS %1 | lpr'. |
|
258 |
||
1729 | 259 |
" |
260 |
self initializeDefaultCommands |
|
261 |
" |
|
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
262 |
|
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
263 |
"Modified: / 12-05-2004 / 11:43:23 / cg" |
1729 | 264 |
! |
265 |
||
3359 | 266 |
initializeFileInfoMappings |
267 |
"these are used by the file browser if a 'file' command is not present in the OS" |
|
268 |
||
269 |
TypeToInfoMapping := Dictionary new. |
|
270 |
||
271 |
TypeToInfoMapping at:'application/x-smalltalk-source' put:'Smalltalk source'. |
|
272 |
TypeToInfoMapping at:'text/html' put:'HTML document'. |
|
273 |
TypeToInfoMapping at:'text/xml' put:'XML document'. |
|
274 |
TypeToInfoMapping at:'application/xml' put:'XML document'. |
|
275 |
TypeToInfoMapping at:'application/x-c-source' put:'C source'. |
|
276 |
TypeToInfoMapping at:'application/x-c-header' put:'C header file'. |
|
277 |
TypeToInfoMapping at:'application/x-cpp-source' put:'C++ source'. |
|
278 |
TypeToInfoMapping at:'application/x-csharp-source' put:'C# source'. |
|
279 |
TypeToInfoMapping at:'application/x-java-source' put:'Java source'. |
|
280 |
TypeToInfoMapping at:'application/x-javascript' put:'Javascript source'. |
|
281 |
TypeToInfoMapping at:'application/x-lisp-source' put:'Lisp source'. |
|
282 |
||
283 |
TypeToInfoMapping at:'application/x-make' put:'make rules'. |
|
284 |
TypeToInfoMapping at:'application/binary' put:'binary object file'. |
|
285 |
||
286 |
" |
|
287 |
self initializeFileInfoMappings |
|
288 |
'foo.H' asFilename mimeTypeFromName |
|
289 |
'foo.o' asFilename mimeTypeFromName |
|
290 |
" |
|
291 |
! |
|
292 |
||
1729 | 293 |
initializeFileNameToMimeTypeMapping |
294 |
"initialize wellKnown facts" |
|
295 |
||
296 |
|types| |
|
297 |
||
298 |
FileSuffixToTypeMapping isNil ifTrue:[ |
|
299 |
FileSuffixToTypeMapping := Dictionary new |
|
300 |
]. |
|
1887 | 301 |
TypeToFileSuffixMapping isNil ifTrue:[ |
302 |
TypeToFileSuffixMapping := Dictionary new |
|
303 |
]. |
|
1729 | 304 |
FilenameToTypeMapping isNil ifTrue:[ |
305 |
FilenameToTypeMapping := Dictionary new. |
|
306 |
]. |
|
307 |
||
308 |
types := OrderedCollection new. |
|
309 |
types addAll:self textTypeList. |
|
310 |
types addAll:self imageTypeList. |
|
311 |
types addAll:self videoTypeList. |
|
312 |
types addAll:self audioTypeList. |
|
313 |
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
|
314 |
types addAll:self osSpecificTypeList. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
315 |
|
1729 | 316 |
types pairWiseDo:[:suff :typeString| |
317 |
|type| |
|
318 |
||
319 |
type := MIMEType fromString:typeString. |
|
320 |
suff isArray ifTrue:[ |
|
1887 | 321 |
suff do:[:s | FileSuffixToTypeMapping at:s put:type]. |
322 |
TypeToFileSuffixMapping at:type put:suff first. |
|
1729 | 323 |
] ifFalse:[ |
1887 | 324 |
FileSuffixToTypeMapping at:suff put:type. |
325 |
TypeToFileSuffixMapping at:type put:suff. |
|
326 |
]. |
|
1729 | 327 |
]. |
328 |
||
329 |
self miscFilenameList pairWiseDo:[:nm :typeString| |
|
330 |
|type| |
|
331 |
||
332 |
type := MIMEType fromString:typeString. |
|
333 |
nm isArray ifTrue:[ |
|
334 |
nm do:[:s | FilenameToTypeMapping at:s put:type] |
|
335 |
] ifFalse:[ |
|
336 |
FilenameToTypeMapping at:nm put:type |
|
337 |
] |
|
338 |
]. |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
339 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
340 |
" |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
341 |
self initializeFileNameToMimeTypeMapping |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
342 |
" |
1729 | 343 |
! |
344 |
||
345 |
initializeImageReaderMappings |
|
3359 | 346 |
"these are used so select an image reader, based on a bitmap image's mime type" |
347 |
||
3295 | 348 |
|rdr| |
349 |
||
1729 | 350 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
351 |
FileSuffixToImageReaderClassMapping := Dictionary new |
|
352 |
]. |
|
353 |
"MIME" TypeToImageReaderClassMapping isNil ifTrue:[ |
|
354 |
TypeToImageReaderClassMapping := Dictionary new |
|
355 |
]. |
|
356 |
||
357 |
"/ setup mimeType to image reader class mapping ... |
|
358 |
TypeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader. |
|
359 |
TypeToImageReaderClassMapping at:'image/gif' put:GIFReader. |
|
360 |
TypeToImageReaderClassMapping at:'image/tiff' put:TIFFReader. |
|
2710 | 361 |
TypeToImageReaderClassMapping at:'image/png' put:PNGReader. |
1729 | 362 |
|
363 |
"/ setup suffix to image reader class mapping ... |
|
364 |
FileSuffixToImageReaderClassMapping at:'jpg' put:JPEGReader. |
|
3295 | 365 |
FileSuffixToImageReaderClassMapping at:'jpeg' put:JPEGReader. |
1729 | 366 |
FileSuffixToImageReaderClassMapping at:'gif' put:GIFReader. |
367 |
FileSuffixToImageReaderClassMapping at:'tif' put:TIFFReader. |
|
3295 | 368 |
FileSuffixToImageReaderClassMapping at:'tiff' put:TIFFReader. |
2710 | 369 |
FileSuffixToImageReaderClassMapping at:'png' put:PNGReader. |
2570 | 370 |
|
3295 | 371 |
"/ some 'used-to-be-optional' readers |
372 |
(rdr := Smalltalk at:#WindowsIconReader) notNil ifTrue:[ |
|
373 |
TypeToImageReaderClassMapping at:'image/bmp' put:rdr. |
|
374 |
TypeToImageReaderClassMapping at:'image/x-MS-bmp' put:rdr. |
|
375 |
TypeToImageReaderClassMapping at:'image/x-MS-ico' put:rdr. |
|
376 |
FileSuffixToImageReaderClassMapping at:'bmp' put:rdr. |
|
377 |
FileSuffixToImageReaderClassMapping at:'ico' put:rdr. |
|
378 |
]. |
|
379 |
(rdr := Smalltalk at:#XBMReader) notNil ifTrue:[ |
|
380 |
TypeToImageReaderClassMapping at:'image/x-xbitmap' put:rdr. |
|
381 |
FileSuffixToImageReaderClassMapping at:'xbm' put:rdr. |
|
382 |
]. |
|
383 |
(rdr := Smalltalk at:#XPMReader) notNil ifTrue:[ |
|
384 |
TypeToImageReaderClassMapping at:'image/x-xpixmap' put:rdr. |
|
385 |
FileSuffixToImageReaderClassMapping at:'pm' put:rdr. |
|
386 |
]. |
|
387 |
(rdr := Smalltalk at:#PBMReader) notNil ifTrue:[ |
|
388 |
TypeToImageReaderClassMapping at:'image/x-portable-pixmap' put:rdr. |
|
389 |
TypeToImageReaderClassMapping at:'image/x-portable-bitmap' put:rdr. |
|
390 |
TypeToImageReaderClassMapping at:'image/x-portable-graymap' put:rdr. |
|
391 |
TypeToImageReaderClassMapping at:'image/x-portable-anymap' put:rdr. |
|
392 |
FileSuffixToImageReaderClassMapping at:'ppm' put:rdr. |
|
393 |
FileSuffixToImageReaderClassMapping at:'pbm' put:rdr. |
|
394 |
FileSuffixToImageReaderClassMapping at:'pgm' put:rdr. |
|
395 |
FileSuffixToImageReaderClassMapping at:'pnm' put:rdr. |
|
396 |
]. |
|
397 |
(rdr := Smalltalk at:#PCXReader) notNil ifTrue:[ |
|
398 |
TypeToImageReaderClassMapping at:'image/x-pcx' put:rdr. |
|
399 |
FileSuffixToImageReaderClassMapping at:'pcx' put:rdr. |
|
400 |
]. |
|
401 |
(rdr := Smalltalk at:#TargaReader) notNil ifTrue:[ |
|
402 |
TypeToImageReaderClassMapping at:'image/x-targa' put:rdr. |
|
403 |
FileSuffixToImageReaderClassMapping at:'tga' put:rdr. |
|
404 |
]. |
|
405 |
(rdr := Smalltalk at:#XWDReader) notNil ifTrue:[ |
|
406 |
TypeToImageReaderClassMapping at:'image/x-xwindowdump' put:rdr. |
|
407 |
TypeToImageReaderClassMapping at:'image/x-windowdump' put:rdr. |
|
408 |
FileSuffixToImageReaderClassMapping at:'xwd' put:rdr. |
|
409 |
]. |
|
410 |
(rdr := Smalltalk at:#BlitImageReader) notNil ifTrue:[ |
|
411 |
TypeToImageReaderClassMapping at:'image/x-blitimage' put:rdr. |
|
412 |
FileSuffixToImageReaderClassMapping at:'48x48x1' put:rdr. |
|
413 |
]. |
|
414 |
(rdr := Smalltalk at:#IrisRGBReader) notNil ifTrue:[ |
|
415 |
TypeToImageReaderClassMapping at:'image/x-rgb' put:rdr. |
|
416 |
FileSuffixToImageReaderClassMapping at:'rgb' put:rdr. |
|
417 |
]. |
|
418 |
(rdr := Smalltalk at:#SunRasterReader) notNil ifTrue:[ |
|
419 |
TypeToImageReaderClassMapping at:'image/x-sunraster' put:rdr. |
|
420 |
FileSuffixToImageReaderClassMapping at:'im8' put:rdr. |
|
421 |
FileSuffixToImageReaderClassMapping at:'icon' put:rdr. |
|
2570 | 422 |
]. |
3295 | 423 |
(rdr := Smalltalk at:#ST80FormReader) notNil ifTrue:[ |
424 |
TypeToImageReaderClassMapping at:'image/x-st80-form' put:rdr. |
|
425 |
FileSuffixToImageReaderClassMapping at:'form' put:rdr. |
|
426 |
]. |
|
427 |
(rdr := Smalltalk at:#FaceReader) notNil ifTrue:[ |
|
428 |
TypeToImageReaderClassMapping at:'image/x-face' put:rdr. |
|
429 |
FileSuffixToImageReaderClassMapping at:'face' put:rdr. |
|
430 |
]. |
|
431 |
(rdr := Smalltalk at:#PCDReader) notNil ifTrue:[ |
|
432 |
TypeToImageReaderClassMapping at:'image/x-photo-cd' put:rdr. |
|
433 |
FileSuffixToImageReaderClassMapping at:'pcd' put:rdr. |
|
434 |
]. |
|
435 |
(rdr := Smalltalk at:#CMURasterReader) notNil ifTrue:[ |
|
436 |
TypeToImageReaderClassMapping at:'image/x-cmu-raster' put:rdr. |
|
437 |
FileSuffixToImageReaderClassMapping at:'ras' put:rdr. |
|
438 |
]. |
|
439 |
||
3359 | 440 |
"/ movie formats - experimental and not yet complete / finished / delivered / published |
3295 | 441 |
"/ (rdr := Smalltalk at:#FLIReader) notNil ifTrue:[ |
442 |
"/ TypeToImageReaderClassMapping at:'video/x-fli' put:rdr. |
|
443 |
"/ FileSuffixToImageReaderClassMapping at:'fli' put:rdr. |
|
444 |
"/ ]. |
|
445 |
"/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ |
|
446 |
"/ TypeToImageReaderClassMapping at:'video/x-msvideo' put:rdr. |
|
447 |
"/ FileSuffixToImageReaderClassMapping at:'avi' put:rdr. |
|
448 |
"/ ]. |
|
449 |
"/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ |
|
450 |
"/ TypeToImageReaderClassMapping at:'video/x-msvideo' put:rdr. |
|
451 |
"/ FileSuffixToImageReaderClassMapping at:'avi' put:rdr. |
|
452 |
"/ ]. |
|
453 |
"/ (rdr := Smalltalk at:#QuickTimeReader) notNil ifTrue:[ |
|
454 |
"/ TypeToImageReaderClassMapping at:'video/quicktime' put:rdr. |
|
455 |
"/ FileSuffixToImageReaderClassMapping at:'qt' put:rdr. |
|
456 |
"/ FileSuffixToImageReaderClassMapping at:'mov' put:rdr. |
|
457 |
"/ FileSuffixToImageReaderClassMapping at:'moov' put:rdr. |
|
458 |
"/ ]. |
|
459 |
"/ (rdr := Smalltalk at:#MPEG2Reader) notNil ifTrue:[ |
|
460 |
"/ TypeToImageReaderClassMapping at:'video/x-mpeg2' put:rdr. |
|
461 |
"/ FileSuffixToImageReaderClassMapping at:'mpg2' put:rdr. |
|
462 |
"/ FileSuffixToImageReaderClassMapping at:'mpv2' put:rdr. |
|
463 |
"/ FileSuffixToImageReaderClassMapping at:'mp2v' put:rdr. |
|
464 |
"/ FileSuffixToImageReaderClassMapping at:'mp2' put:rdr. |
|
465 |
"/ ]. |
|
466 |
"/ (rdr := Smalltalk at:#MPEGReader) notNil ifTrue:[ |
|
467 |
"/ TypeToImageReaderClassMapping at:'video/mpeg' put:rdr. |
|
468 |
"/ FileSuffixToImageReaderClassMapping at:'mpg' put:rdr. |
|
469 |
"/ FileSuffixToImageReaderClassMapping at:'mpeg' put:rdr. |
|
470 |
"/ FileSuffixToImageReaderClassMapping at:'mpe' put:rdr. |
|
471 |
"/ FileSuffixToImageReaderClassMapping at:'mpv' put:rdr. |
|
472 |
"/ FileSuffixToImageReaderClassMapping at:'vps' put:rdr. |
|
473 |
"/ FileSuffixToImageReaderClassMapping at:'mpegv' put:rdr. |
|
474 |
"/ ]. |
|
475 |
"/ (rdr := Smalltalk at:#SGIMovieReader) notNil ifTrue:[ |
|
476 |
"/ TypeToImageReaderClassMapping at:'video/x-sgi-movie' put:rdr. |
|
477 |
"/ FileSuffixToImageReaderClassMapping at:'movie' put:rdr. |
|
478 |
"/ ]. |
|
2298 | 479 |
! |
480 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
481 |
initializeParenthesisSpecMappings |
3359 | 482 |
"these are used by the editors to mark matching parenthesis" |
483 |
||
2298 | 484 |
|spec| |
485 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
486 |
TypeToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
487 |
SuffixToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
488 |
|
2298 | 489 |
"/ ST/X spec |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
490 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
491 |
spec at:#open put:#( $( $[ ${ ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
492 |
spec at:#close put:#( $) $] $} ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
493 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
494 |
spec at:#eolComment put:'"/'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
495 |
TypeToParenthesisSpecMapping at:'application/x-smalltalk-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
496 |
|
2479 | 497 |
"/ XML & HTML |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
498 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
499 |
spec at:#open put:#( $< ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
500 |
spec at:#close put:#( $> ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
501 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
502 |
#( 'text/html' 'text/xml' 'application/xml' ) do:[:eachXMLType | |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
503 |
TypeToParenthesisSpecMapping at:eachXMLType put:spec |
2298 | 504 |
]. |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
505 |
|
3359 | 506 |
"/ ANSI-c, Java, C# |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
507 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
508 |
spec at:#open put:#( $( $[ ${ ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
509 |
spec at:#close put:#( $) $] $} ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
510 |
spec at:#ignore put:#( $' $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
511 |
spec at:#eolComment put:'//'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
512 |
TypeToParenthesisSpecMapping at:'application/x-c-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
513 |
TypeToParenthesisSpecMapping at:'application/x-cpp-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
514 |
TypeToParenthesisSpecMapping at:'application/x-csharp-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
515 |
TypeToParenthesisSpecMapping at:'application/x-java-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
516 |
TypeToParenthesisSpecMapping at:'application/x-javascript' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
517 |
|
3359 | 518 |
"/ Lisp / Scheme |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
519 |
spec := IdentityDictionary new. |
3039 | 520 |
spec at:#open put:#( $( $[ ). |
521 |
spec at:#close put:#( $) $] ). |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
522 |
spec at:#ignore put:#( $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
523 |
spec at:#eolComment put:';'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
524 |
TypeToParenthesisSpecMapping at:'application/x-lisp-source' put:spec. |
2298 | 525 |
|
526 |
"Created: / 10-04-2007 / 15:16:37 / cg" |
|
1729 | 527 |
! ! |
528 |
||
529 |
!MIMETypes class methodsFor:'initialization-lists'! |
|
530 |
||
531 |
applicationCompressorsAndArchiveTypeList |
|
1604 | 532 |
^ #( |
1890 | 533 |
'tar' 'application/x-tar' |
534 |
'gtar' 'application/x-gtar' |
|
1891 | 535 |
('tgz' 'tar.gz') 'application/x-tar-gzip-compressed' "/ 'application/x-tar-compressed' |
536 |
('tar.bz2') 'application/x-tar-bzip2-compressed' |
|
1890 | 537 |
'zip' 'application/x-zip-compressed' |
538 |
'bz2' 'application/x-bzip2-compressed' |
|
539 |
('gz' 'z') 'application/x-gzip-compressed' |
|
540 |
'cpio' 'application/x-cpio' |
|
541 |
'shar' 'application/x-shar' |
|
542 |
'jar' 'application/java-archive' |
|
543 |
'sar' 'application/x-squeak-archive' |
|
544 |
'sit' 'application/x-stuffit' |
|
545 |
'hqx' 'application/mac-binhex40' |
|
546 |
'cpt' 'application/mac-compactpro' |
|
1604 | 547 |
) |
548 |
! |
|
645 | 549 |
|
1609 | 550 |
applicationMiscTypeList |
551 |
"misc applications" |
|
552 |
||
553 |
^ #( |
|
554 |
('a' 'o' 'obj' ) 'application/binary' |
|
2968 | 555 |
('lic') 'application/license' |
1609 | 556 |
('dll' 'so') 'application/shared-library' |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
557 |
|
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
558 |
('ets') 'application/x-expecco-testsuite' |
3104 | 559 |
('etr') 'application/x-expecco-testrepository' |
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
560 |
('elf') 'application/x-expecco-logfile' |
2886
22b48a4da285
comment/format in: #initializeFileNameToMimeTypeMapping
sr
parents:
2830
diff
changeset
|
561 |
('expeccolicense') 'application/x-expecco-license' |
2888 | 562 |
('expeccopatch') 'application/x-expecco-patch' |
1609 | 563 |
) |
2886
22b48a4da285
comment/format in: #initializeFileNameToMimeTypeMapping
sr
parents:
2830
diff
changeset
|
564 |
|
2968 | 565 |
"Modified: / 03-11-2011 / 10:42:28 / sr" |
1609 | 566 |
! |
567 |
||
1604 | 568 |
applicationProgLangTypeList |
3020
3f9c74ff0975
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
569 |
"applications for programming languages" |
713 | 570 |
|
1604 | 571 |
^ #( |
1609 | 572 |
('st' 'cls' 'rc') 'application/x-smalltalk-source' |
1604 | 573 |
'sif' 'application/x-smalltalk-source-sif' |
1668 | 574 |
'pac' 'application/x-smalltalk-dolphin-package' |
1778 | 575 |
|
576 |
'sts' 'application/x-squeak-source' |
|
577 |
'pr' 'application/x-squeak-project' |
|
578 |
||
1604 | 579 |
'c' 'application/x-c-source' |
580 |
('cc' 'cpp') 'application/x-cpp-source' |
|
2479 | 581 |
'cs' 'application/x-csharp-source' |
1609 | 582 |
('h' 'hi') 'application/x-c-header' |
1604 | 583 |
('js' 'mocha') 'application/x-javascript' |
584 |
('java' 'jav') 'application/x-java-source' |
|
585 |
'sh' 'application/x-sh' |
|
586 |
'csh' 'application/x-csh' |
|
587 |
'tcl' 'application/x-tcl' |
|
588 |
'pl' 'application/x-perl' |
|
3020
3f9c74ff0975
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
589 |
'dart' 'application/x-dart' |
1604 | 590 |
'mak' 'application/x-make' |
591 |
'bat' 'application/x-batch-script' |
|
3008 | 592 |
('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source' |
593 |
||
2912
f3466ea0810b
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
2911
diff
changeset
|
594 |
('lisp' 'lsp' 'scm' 'ss' |
f3466ea0810b
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
2911
diff
changeset
|
595 |
'arc' 'cl' 'brg') 'application/x-lisp-source' |
1604 | 596 |
) |
2298 | 597 |
|
3020
3f9c74ff0975
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
598 |
"Modified (comment): / 21-08-2012 / 20:55:13 / cg" |
1604 | 599 |
! |
1561 | 600 |
|
1604 | 601 |
applicationTextTypeList |
1606 | 602 |
"text applications" |
1604 | 603 |
|
604 |
^ #( |
|
605 |
('ps' 'eps') 'application/postscript' |
|
1778 | 606 |
"/ 'ai' 'application/postscript' |
1604 | 607 |
'pdf' 'application/pdf' |
608 |
'rtf' 'application/rtf' |
|
1778 | 609 |
"/ 'rtf' 'text/rtf' ???? |
3008 | 610 |
'ics' 'text/calendar' |
611 |
'doc' 'application/ms-word-document' |
|
1778 | 612 |
"/ 'doc' 'application/winword' |
613 |
'swf' 'application/x-shockwave-flash' |
|
614 |
('ppt' 'ppz' 'pot' 'pps') 'application/mspowerpoint' |
|
2028 | 615 |
'xls' 'application/x-excel' |
616 |
'slk' 'application/vnd.ms-excel' |
|
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
617 |
'txt' 'text/plain' |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
618 |
'xlsx' 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
1604 | 619 |
) |
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
620 |
|
3008 | 621 |
"Modified: / 26-05-2012 / 15:27:30 / cg" |
1604 | 622 |
! |
623 |
||
624 |
applicationTypeList |
|
1606 | 625 |
"applications" |
1604 | 626 |
|
1729 | 627 |
|typeList| |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
628 |
|
1729 | 629 |
typeList := OrderedCollection new. |
630 |
typeList addAll:self applicationProgLangTypeList. |
|
631 |
typeList addAll:self applicationTextTypeList. |
|
632 |
typeList addAll:self applicationCompressorsAndArchiveTypeList. |
|
633 |
typeList addAll:self applicationMiscTypeList. |
|
1616 | 634 |
|
1729 | 635 |
^ typeList |
1604 | 636 |
! |
637 |
||
638 |
audioTypeList |
|
1606 | 639 |
"audio formats ..." |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
640 |
|
1604 | 641 |
^ #( |
1720 | 642 |
('au' 'snd') 'audio/basic' |
1778 | 643 |
('ra') 'audio/x-realaudio' |
644 |
('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
|
645 |
"/ cg: see unixSpecific / windowsSpecific |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
646 |
"/ 'rpm' 'audio/x-pn-realaudio-plugin' |
3008 | 647 |
('mpa' 'mpega' 'mpga') 'audio/mpeg' |
1778 | 648 |
"/ 'mp3' 'audio/x-mp3' |
649 |
('mp3' 'mp2') 'audio/mpeg' |
|
1604 | 650 |
'wav' 'audio/x-wav' |
651 |
('aif' 'aiff' 'aifc') 'audio/x-aiff' |
|
1778 | 652 |
('midi' 'mid') 'audio/midi' |
1604 | 653 |
) |
3008 | 654 |
|
655 |
"Modified: / 26-05-2012 / 15:23:45 / cg" |
|
1604 | 656 |
! |
657 |
||
658 |
imageTypeList |
|
659 |
||
660 |
^ #( |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
661 |
"/ image formats ... |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
662 |
|
1216 | 663 |
('jpg' 'jpeg') 'image/jpeg' |
1188 | 664 |
'gif' 'image/gif' |
665 |
('tif' 'tiff') 'image/tiff' |
|
3295 | 666 |
('xbm' 'bm') 'image/x-xbitmap' |
1188 | 667 |
'xpm' 'image/x-xpixmap' |
1720 | 668 |
'png' 'image/png' |
1188 | 669 |
'pcd' 'image/x-photo-cd' |
670 |
'bmp' 'image/x-MS-bmp' |
|
671 |
'rgb' 'image/x-rgb' |
|
672 |
'ppm' 'image/x-portable-pixmap' |
|
673 |
'pgm' 'image/x-portable-graymap' |
|
674 |
'pbm' 'image/x-portable-bitmap' |
|
675 |
'pnm' 'image/x-portable-anymap' |
|
676 |
'xwd' 'image/x-xwindowdump' |
|
677 |
'ras' 'image/x-cmu-raster' |
|
1216 | 678 |
'tga' 'image/x-targa' |
2020 | 679 |
'ico' 'image/x-ico' |
1604 | 680 |
) |
681 |
! |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
682 |
|
1609 | 683 |
miscFilenameList |
3104 | 684 |
"other formats (not by suffix, but by fileName instead) ..." |
1609 | 685 |
|
686 |
^ #( |
|
2113 | 687 |
('makefile' 'make.proto' 'make.spec' 'nt.mak') 'application/x-make' |
2830 | 688 |
('exe' 'bin' 'com') 'application/octet-stream' |
2113 | 689 |
('class') 'application/octet-stream' |
2375 | 690 |
('top') 'application/x-waltop-digital-notepad' |
1609 | 691 |
) |
692 |
! |
|
693 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
694 |
osSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
695 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
696 |
^ self windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
697 |
]. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
698 |
^ self unixSpecificTypeList |
2023 | 699 |
|
700 |
" |
|
701 |
self osSpecificTypeList |
|
702 |
" |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
703 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
704 |
|
1604 | 705 |
textTypeList |
706 |
"/ misc text ... |
|
707 |
||
708 |
^ #( |
|
1887 | 709 |
('html' 'htm' 'shtml') 'text/html' |
1604 | 710 |
('txt' 'text') 'text/plain' |
1680 | 711 |
'xml' 'text/xml' |
1777 | 712 |
'css' 'text/css' |
2432 | 713 |
'csv' 'text/csv' |
1604 | 714 |
) |
715 |
! |
|
716 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
717 |
unixSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
718 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
719 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
720 |
"/ 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
|
721 |
"/ 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
|
722 |
'rpm' 'application/x-rpm' |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
723 |
) |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
724 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
725 |
|
1604 | 726 |
videoTypeList |
727 |
"/ video formats ... |
|
728 |
||
729 |
^ #( |
|
1720 | 730 |
('qt' 'mov' 'moov') 'video/quicktime' |
731 |
('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg' |
|
1604 | 732 |
'movie' 'video/x-sgi-movie' |
1820 | 733 |
('avi' 'wmv' 'asf') 'video/x-msvideo' |
1604 | 734 |
('mpv2' 'mp2v' 'mp2' 'mpeg2') 'video/x-mpeg2' |
1680 | 735 |
'rm' 'application/vnd.rn-realmedia' |
736 |
'rv' 'video/x-pn-realvideo' |
|
3295 | 737 |
'fli' 'video/x-fli' |
1778 | 738 |
) |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
739 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
740 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
741 |
windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
742 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
743 |
"/ 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
|
744 |
"/ 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
|
745 |
'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
|
746 |
) |
643 | 747 |
! ! |
748 |
||
1729 | 749 |
!MIMETypes class methodsFor:'obsolete'! |
1489 | 750 |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
751 |
defaultCommandForMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
752 |
<resource: #obsolete> |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
753 |
self obsoleteMethodWarning:'use #defaultCommandTemplateToOpenMimeType:'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
754 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
755 |
^ self defaultCommandTemplateToOpenMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
756 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
757 |
" |
2758
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
758 |
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf' |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
759 |
" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
760 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
761 |
"Created: / 12-05-2004 / 11:09:22 / cg" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
762 |
"Modified: / 12-05-2004 / 11:16:53 / cg" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
763 |
! |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
764 |
|
1729 | 765 |
fontForCharset:aCharSetName |
766 |
"return the font-encoding for an iso-charset" |
|
1489 | 767 |
|
1981 | 768 |
<resource:#obsolete> |
1729 | 769 |
self obsoleteMethodWarning:'use FontDescription >> fontNamePatternForCharset:'. |
770 |
^ FontDescription fontNamePatternForCharset:aCharSetName. |
|
1489 | 771 |
|
772 |
" |
|
1729 | 773 |
MIMETypes fontForCharset:'iso2022-jp' |
774 |
MIMETypes fontForCharset:'euc-jp' |
|
1472 | 775 |
" |
776 |
||
1729 | 777 |
"Modified: / 1.8.1998 / 17:00:57 / cg" |
778 |
! ! |
|
1472 | 779 |
|
1729 | 780 |
!MIMETypes class methodsFor:'queries'! |
1472 | 781 |
|
647 | 782 |
defineImageType:mimeType suffix:aSuffix reader:aReaderClass |
783 |
"register an image reader." |
|
784 |
||
785 |
aSuffix notNil ifTrue:[ |
|
786 |
self imageReaderForSuffix:aSuffix put:aReaderClass. |
|
787 |
]. |
|
788 |
||
789 |
mimeType notNil ifTrue:[ |
|
790 |
self imageReaderForType:mimeType put:aReaderClass |
|
791 |
]. |
|
792 |
||
793 |
(aSuffix notNil and:[mimeType notNil]) ifTrue:[ |
|
794 |
self mimeTypeForSuffix:aSuffix put:mimeType |
|
795 |
]. |
|
796 |
! |
|
797 |
||
3359 | 798 |
fileInfoForMimeType:mimeType |
799 |
"given a mimeType, return an info string similar to what the unix 'file' command |
|
800 |
provides. This info here is returned by systems which have no file (i.e. MSDOS) and |
|
801 |
for types of which file does not know about (smalltalk files, for example)" |
|
802 |
||
803 |
^ TypeToInfoMapping at:mimeType ifAbsent:nil |
|
804 |
||
805 |
" |
|
806 |
self fileInfoForMimeType:(MIMEType fromString:'image/gif') |
|
807 |
" |
|
808 |
! |
|
809 |
||
643 | 810 |
fileSuffixToImageReaderMapping |
1021 | 811 |
"return the suffix-to-imageReader mapping" |
812 |
||
643 | 813 |
^ FileSuffixToImageReaderClassMapping ? #() |
814 |
||
1021 | 815 |
"Modified: / 1.8.1998 / 17:00:11 / cg" |
643 | 816 |
! |
817 |
||
818 |
imageFileSuffixes |
|
1021 | 819 |
"return a collection with known file suffixes" |
820 |
||
643 | 821 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()]. |
822 |
^ FileSuffixToImageReaderClassMapping keys |
|
823 |
||
1021 | 824 |
"Created: / 30.6.1997 / 22:04:48 / cg" |
825 |
"Modified: / 1.8.1998 / 17:01:26 / cg" |
|
643 | 826 |
! |
827 |
||
3014
e6d9a204da08
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
3012
diff
changeset
|
828 |
mimeTypeForFilename:filenameOrString |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
829 |
"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
|
830 |
|
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
831 |
|type filename lcFilename suff suff2| |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
832 |
|
3014
e6d9a204da08
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
3012
diff
changeset
|
833 |
filename := filenameOrString asFilename. |
1474 | 834 |
|
835 |
lcFilename := filename baseName asLowercase. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
836 |
type := FilenameToTypeMapping at:lcFilename ifAbsent:nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
837 |
type isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
838 |
"/ allow for fallback ... |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
839 |
type := OperatingSystem mimeTypeForFilename:lcFilename. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
840 |
"/ 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
|
841 |
"/ 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
|
842 |
"/ the OS. |
1275 | 843 |
"/ type isNil ifTrue:[ |
844 |
"/ FilenameToTypeMapping at:lcFilename put:#unknown |
|
845 |
"/ ]. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
846 |
]. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
847 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
848 |
type == #unknown ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
849 |
type := nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
850 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
851 |
|
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
852 |
type isNil ifTrue:[ |
1473 | 853 |
suff := filename suffix. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
854 |
suff size ~~ 0 ifTrue:[ |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
855 |
"/ sigh - special code for multiple-suffices... |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
856 |
"/ .tar.gz -> tgz |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
857 |
suff2 := filename withoutSuffix suffix. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
858 |
suff2 size > 0 ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
859 |
type := self mimeTypeForSuffix:(suff2 , '.' , suff). |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
860 |
]. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
861 |
type isNil ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
862 |
type := self mimeTypeForSuffix:suff |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
863 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
864 |
] |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
865 |
]. |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
866 |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
867 |
^ type |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
868 |
|
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
869 |
" |
2820 | 870 |
MIMETypes mimeTypeForFilename:'typeinst.dvi' |
871 |
MIMETypes mimeTypeForFilename:'foo.tar' |
|
872 |
MIMETypes mimeTypeForFilename:'foo.tgz' |
|
873 |
MIMETypes mimeTypeForFilename:'foo.tar.gz' |
|
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
874 |
MIMETypes mimeTypeForFilename:'foo.txt' |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
875 |
" |
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
876 |
|
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
877 |
"Modified: / 10-05-2011 / 11:55:18 / cg" |
3014
e6d9a204da08
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
3012
diff
changeset
|
878 |
"Modified (format): / 28-07-2012 / 09:39:15 / cg" |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
879 |
! |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
880 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
881 |
mimeTypeForFilename:filename put:mimeType |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
882 |
"register a mime type for a filename" |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
883 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
884 |
FilenameToTypeMapping isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
885 |
FilenameToTypeMapping := Dictionary new |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
886 |
]. |
1612 | 887 |
FilenameToTypeMapping at:filename put:(MIMEType fromString:mimeType asLowercase) |
1611 | 888 |
! |
889 |
||
643 | 890 |
mimeTypeForSuffix:suffix |
1021 | 891 |
"given a file suffix, return the mime-type" |
892 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
893 |
|type lcSuffix| |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
894 |
|
1837 | 895 |
suffix = LastSuffix ifTrue:[ |
896 |
^ LastType |
|
897 |
]. |
|
898 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
899 |
lcSuffix := suffix asLowercase. |
1837 | 900 |
type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil. |
901 |
type isNil ifTrue:[ |
|
902 |
"/ allow for fallback ... |
|
903 |
type := OperatingSystem mimeTypeForSuffix:lcSuffix. |
|
904 |
"/ the special value #unknown is returned as nil; |
|
905 |
"/ this avoids constant retry if a mimeType is not known in the OS. |
|
906 |
||
907 |
type := type ? #unknown. |
|
908 |
FileSuffixToTypeMapping at:lcSuffix put:type. |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
909 |
]. |
1837 | 910 |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
911 |
type == #unknown ifTrue:[ |
1837 | 912 |
type := nil. |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
913 |
]. |
1840 | 914 |
type notNil ifTrue:[ |
915 |
LastSuffix := suffix. |
|
916 |
LastType := MIMEType fromString:type. |
|
917 |
^ LastType |
|
918 |
]. |
|
1841 | 919 |
^ type |
643 | 920 |
|
1666 | 921 |
" |
1840 | 922 |
self mimeTypeForSuffix:'gif' |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
923 |
self mimeTypeForSuffix:'rpm' |
2891 | 924 |
self mimeTypeForSuffix:'zip' |
1666 | 925 |
" |
926 |
||
2891 | 927 |
"Created: / 30-06-1997 / 21:55:51 / cg" |
928 |
"Modified: / 14-02-2011 / 17:14:34 / cg" |
|
643 | 929 |
! |
930 |
||
931 |
mimeTypeForSuffix:suffix put:mimeType |
|
1021 | 932 |
"register a mime type for a file suffix" |
933 |
||
643 | 934 |
FileSuffixToTypeMapping isNil ifTrue:[ |
935 |
FileSuffixToTypeMapping := Dictionary new |
|
936 |
]. |
|
937 |
FileSuffixToTypeMapping at:suffix put:mimeType asLowercase |
|
938 |
||
1021 | 939 |
"Created: / 30.6.1997 / 21:56:20 / cg" |
940 |
"Modified: / 1.8.1998 / 17:03:18 / cg" |
|
1593 | 941 |
! |
942 |
||
943 |
mimeTypeForSuffixMapping |
|
944 |
||
945 |
^ FileSuffixToTypeMapping |
|
1611 | 946 |
! |
947 |
||
2023 | 948 |
mimeTypeFromString:mimeTypeString |
949 |
"given a mime-type for a string" |
|
950 |
||
951 |
^ MIMEType fromString:mimeTypeString |
|
952 |
||
953 |
" |
|
954 |
self mimeTypeFromString:'image/gif' |
|
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
955 |
self mimeTypeFromString:'application/x-expecco-testsuite' |
2023 | 956 |
" |
957 |
! |
|
958 |
||
1611 | 959 |
mimeTypeOfContents:filename |
960 |
"given a filename, scan the contents, return the mime-type or nil, if unknown" |
|
961 |
||
1612 | 962 |
|typeString| |
963 |
||
964 |
typeString := filename mimeTypeOfContents. |
|
965 |
typeString isNil ifTrue:[^ nil]. |
|
966 |
^ MIMEType fromString:typeString. |
|
1887 | 967 |
! |
968 |
||
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
969 |
mimeTypeOfData:someData |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
970 |
"this tries to guess the mime type of contents of someData. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
971 |
Returns nil, if unknown. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
972 |
This is done using some heuristics, and may need some improvement" |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
973 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
974 |
|buffer lcBuffer size idx idx2| |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
975 |
|
2583 | 976 |
someData isEmptyOrNil ifTrue:[^ nil]. |
977 |
||
978 |
size := 2048 min:someData size. |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
979 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
980 |
"/ read some data from the file ... |
2583 | 981 |
buffer := (someData copyTo:size) asString. |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
982 |
lcBuffer := buffer asLowercase. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
983 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
984 |
(idx := lcBuffer findString:'mimetype:') ~~ 0 ifTrue:[ |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
985 |
idx := idx + 'mimetype:' size. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
986 |
idx := lcBuffer indexOfNonSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
987 |
idx2 := lcBuffer indexOfSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
988 |
idx2 > idx ifTrue:[ |
2583 | 989 |
^ MIMEType fromString:(lcBuffer copyFrom:idx to:idx2-1) |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
990 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
991 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
992 |
|
2924 | 993 |
"/ real starters |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
994 |
#( |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
995 |
( #[16r4C 16r00 16r00 16r00 16r01 16r14 16r02 16r00 16r00 16r00 16r00 16r00 16rC0 16r00 16r00 16r00 16r00 16r00 16r00 16r46] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
996 |
#'application/x-ms-shortcut' ) |
2924 | 997 |
( 'ITOLITLS' |
998 |
#'application/x-ms-reader' ) |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
999 |
( 'WALTOP' |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1000 |
#'application/x-waltop-digital-notepad' ) |
2892 | 1001 |
('PK' |
1002 |
#'application/x-zip-compressed') |
|
3113 | 1003 |
('<?xml' |
1004 |
#'text/xml') |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1005 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1006 |
|patternString| |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1007 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1008 |
patternString := pattern asString. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1009 |
(buffer startsWith:patternString) ifTrue:[ |
2583 | 1010 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1011 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1012 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1013 |
|
2924 | 1014 |
"/ somewhere near the beginning |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1015 |
#( |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1016 |
('<body:' #'text/html') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1017 |
('%!!ps-adobe' #'application/postscript') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1018 |
('%PDF-' #'application/pdf') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1019 |
('#!! /bin/sh' #'application/x-sh') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1020 |
('#!!/bin/sh' #'application/x-sh') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1021 |
"/ ('#!! /bin/bash' 'application/x-bash') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1022 |
"/ ('#!!/bin/bash' 'application/x-bash') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1023 |
|
3113 | 1024 |
('---- encoding: ' #'application/x-smalltalk-source') |
1025 |
('---- timestamp ' #'application/x-smalltalk-source') |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1026 |
('from dolphin' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1027 |
('from visualworks' #'application/x-smalltalk-source') |
3359 | 1028 |
('from squeak' #'application/x-smalltalk-source') |
1029 |
('from smalltalk/x' #'application/x-smalltalk-source') |
|
1030 |
('"{ Package:' #'application(x-smalltalk-source') |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1031 |
('categoriesforclass' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1032 |
('methodsfor!!' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1033 |
('subclass:' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1034 |
('methodsfor:' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1035 |
('interchangeversion:' #'application/x-smalltalk-source-sif') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1036 |
('subclass:' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1037 |
('methodsfor:' #'application/x-smalltalk-source') |
3332 | 1038 |
('Application create:' #'application/x-smalltalk-source') |
1039 |
('becomeDefault!!' #'application/x-smalltalk-source') |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1040 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1041 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1042 |
(lcBuffer findString:pattern) ~~ 0 ifTrue:[ |
2583 | 1043 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1044 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1045 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1046 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1047 |
(idx := lcBuffer findString:'<h') ~~ 0 ifTrue:[ |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1048 |
((lcBuffer continuesWith:'<head' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1049 |
or:[(lcBuffer continuesWith:'<html' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1050 |
or:[(lcBuffer continuesWith:'<h1' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1051 |
or:[(lcBuffer continuesWith:'<h2' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1052 |
or:[(lcBuffer continuesWith:'<h3' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1053 |
or:[(lcBuffer continuesWith:'<h4' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1054 |
or:[(lcBuffer continuesWith:'<h5' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1055 |
or:[(lcBuffer continuesWith:'<h6' startingAt:idx)]]]]]]]) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1056 |
ifTrue:[ |
2583 | 1057 |
^ MIMEType fromString:'text/html' |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1058 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1059 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1060 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1061 |
[size ~~ 0 and:[(buffer at:size) isPrintable]] whileTrue:[size := size - 1]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1062 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1063 |
size == 0 ifTrue:[ |
2583 | 1064 |
^ MIMEType fromString:'text/plain' |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1065 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1066 |
^ nil |
2891 | 1067 |
|
2924 | 1068 |
"Modified: / 12-07-2011 / 19:08:17 / cg" |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1069 |
! |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1070 |
|
1887 | 1071 |
suffixForMimeType:mimeType |
1072 |
"given a file suffix, return the mime-type" |
|
1073 |
||
1074 |
^ TypeToFileSuffixMapping at:mimeType ifAbsent:nil |
|
1075 |
||
1076 |
" |
|
1077 |
self suffixForMimeType:(MIMEType fromString:'image/gif') |
|
1078 |
" |
|
1079 |
||
1080 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
1081 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
1082 |
! |
|
1083 |
||
1084 |
suffixForMimeTypeString:mimeTypeString |
|
1085 |
"given a file suffix, return the mime-type" |
|
1086 |
||
1087 |
^ self suffixForMimeType:(MIMEType fromString:mimeTypeString) |
|
1088 |
||
1089 |
" |
|
1090 |
self suffixForMimeTypeString:'image/gif' |
|
1091 |
" |
|
1092 |
||
1093 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
1094 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
1612 | 1095 |
! ! |
1096 |
||
2116 | 1097 |
!MIMETypes class methodsFor:'queries-applications'! |
1098 |
||
2117 | 1099 |
defaultCommandPerMIME |
1100 |
"returns the collection which is used to map MIME-type to command-templates." |
|
1101 |
||
1102 |
"TODO: move this to OS/UserPreferences" |
|
1103 |
||
1104 |
DefaultCommandPerMIMEPerOS isNil ifTrue:[ |
|
1105 |
self initializeDefaultCommands |
|
1106 |
]. |
|
1107 |
OperatingSystem isUNIXlike ifTrue:[ |
|
1108 |
^ DefaultCommandPerMIMEPerOS at:#unix |
|
1109 |
]. |
|
1110 |
^ DefaultCommandPerMIMEPerOS at:#win32 |
|
2942
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1111 |
|
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1112 |
" |
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1113 |
MIMETypes defaultCommandPerMIME |
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1114 |
" |
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1115 |
|
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1116 |
"Modified (comment): / 16-09-2011 / 16:20:12 / cg" |
2117 | 1117 |
! |
1118 |
||
2116 | 1119 |
defaultCommandTemplateToOpenMimeType:mimeType |
1120 |
|cmd| |
|
1121 |
||
1122 |
cmd := self defaultCommandPerMIME at:mimeType ifAbsent:nil. |
|
1123 |
cmd isNil ifTrue:[ |
|
1124 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1125 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:mimeType |
|
1126 |
]. |
|
1127 |
]. |
|
1128 |
^ cmd |
|
1129 |
||
1130 |
" |
|
1131 |
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf' |
|
2118 | 1132 |
MIMETypes defaultCommandTemplateToOpenMimeType:'text/html' |
2116 | 1133 |
" |
1134 |
||
1135 |
"Created: / 12-05-2004 / 11:09:22 / cg" |
|
1136 |
"Modified: / 12-05-2004 / 11:16:53 / cg" |
|
1137 |
! |
|
1138 |
||
1139 |
defaultCommandTemplateToPrintMimeType:mimeType |
|
1140 |
|cmd| |
|
1141 |
||
1142 |
cmd := self defaultPrintCommandPerMIME at:mimeType ifAbsent:nil. |
|
1143 |
cmd isNil ifTrue:[ |
|
1144 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1145 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToPrintMimeType:mimeType |
|
1146 |
]. |
|
1147 |
]. |
|
1148 |
^ cmd |
|
1149 |
||
1150 |
" |
|
1151 |
MIMETypes defaultCommandTemplateToPrintMimeType:'application/pdf' |
|
1152 |
" |
|
2117 | 1153 |
! |
1154 |
||
1155 |
defaultPrintCommandPerMIME |
|
1156 |
"returns the collection which is used to map MIME-type to printing command-templates." |
|
1157 |
||
1158 |
"TODO: move this to OS/UserPreferences" |
|
1159 |
||
1160 |
DefaultPrintCommandPerMIMEPerOS isNil ifTrue:[ |
|
1161 |
self initializeDefaultCommands |
|
1162 |
]. |
|
1163 |
OperatingSystem isUNIXlike ifTrue:[ |
|
1164 |
^ DefaultPrintCommandPerMIMEPerOS at:#unix |
|
1165 |
]. |
|
1166 |
^ DefaultPrintCommandPerMIMEPerOS at:#win32 |
|
2116 | 1167 |
! ! |
1168 |
||
1729 | 1169 |
!MIMETypes class methodsFor:'queries-image formats'! |
1170 |
||
1171 |
imageReaderClasses |
|
1172 |
"return a collection of registered image reader classes" |
|
1173 |
||
1174 |
|setOfClasses| |
|
1175 |
||
1176 |
setOfClasses := IdentitySet new. |
|
1177 |
FileSuffixToImageReaderClassMapping notNil ifTrue:[ |
|
1178 |
FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
1179 |
setOfClasses add:cls |
|
1180 |
]. |
|
1181 |
]. |
|
1182 |
TypeToImageReaderClassMapping notNil ifTrue:[ |
|
1183 |
TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
1184 |
setOfClasses add:cls |
|
1185 |
]. |
|
1186 |
]. |
|
1187 |
^ setOfClasses |
|
1188 |
||
1189 |
"Created: / 30.6.1997 / 22:03:42 / cg" |
|
1190 |
"Modified: / 1.8.1998 / 16:59:52 / cg" |
|
1191 |
! |
|
1192 |
||
1193 |
imageReaderForSuffix:aSuffix |
|
1194 |
"given a file suffix, return an approriate image reader class" |
|
1195 |
||
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1196 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1197 |
self initializeImageReaderMappings |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1198 |
]. |
1729 | 1199 |
^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil |
1200 |
||
1201 |
"Created: / 30.6.1997 / 21:59:11 / cg" |
|
1202 |
"Modified: / 1.8.1998 / 17:01:58 / cg" |
|
1203 |
! |
|
1204 |
||
1205 |
imageReaderForSuffix:aSuffix put:aReaderClass |
|
1206 |
"register an image reader for a file suffix" |
|
1207 |
||
1208 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
|
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1209 |
self initializeImageReaderMappings |
1729 | 1210 |
]. |
1211 |
FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass |
|
1212 |
||
1213 |
"Created: / 30.6.1997 / 21:59:43 / cg" |
|
1214 |
"Modified: / 1.8.1998 / 17:02:14 / cg" |
|
1215 |
! |
|
1216 |
||
1217 |
imageReaderForType:mimeTypeString |
|
1218 |
"given a mime-type, return an approriate image reader class" |
|
1219 |
||
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1220 |
TypeToImageReaderClassMapping isNil ifTrue:[ |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1221 |
self initializeImageReaderMappings |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1222 |
]. |
1729 | 1223 |
^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil |
1224 |
||
1225 |
"Created: / 30.6.1997 / 21:56:01 / cg" |
|
1226 |
"Modified: / 1.8.1998 / 17:02:28 / cg" |
|
1227 |
! |
|
1228 |
||
1229 |
imageReaderForType:mimeTypeString put:aReaderClass |
|
1230 |
"register an image reader for a mime-type" |
|
1231 |
||
1232 |
TypeToImageReaderClassMapping isNil ifTrue:[ |
|
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1233 |
self initializeImageReaderMappings |
1729 | 1234 |
]. |
1235 |
TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass |
|
1236 |
||
1237 |
"Created: / 30.6.1997 / 21:56:11 / cg" |
|
1238 |
"Modified: / 1.8.1998 / 17:02:40 / cg" |
|
1239 |
! ! |
|
1240 |
||
1241 |
!MIMETypes class methodsFor:'queries-language syntax'! |
|
1242 |
||
1243 |
commentStringsForFilename:aFilename |
|
1244 |
"return a useful comment definition; heuristics for now. |
|
1245 |
The returned value is an array of 2 elements; |
|
1246 |
the first is the end-of-line comment string (or nil); |
|
1247 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1248 |
||
1249 |
|mime| |
|
1250 |
||
1251 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1252 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) |
|
1253 |
||
1254 |
" |
|
1255 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1256 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1257 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1925 | 1258 |
MIMETypes commentStringsForFilename:'Foo.html'. |
1729 | 1259 |
" |
1260 |
! |
|
1261 |
||
1262 |
commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString |
|
1263 |
"return a useful comment definition; heuristics for now. |
|
1264 |
The returned value is an array of 2 elements; |
|
1265 |
the first is the end-of-line comment string (or nil); |
|
1266 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1267 |
||
1268 |
|mime| |
|
1269 |
||
1270 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1271 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString |
|
1272 |
||
1273 |
" |
|
1274 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1275 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1276 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1277 |
" |
|
1278 |
! |
|
1279 |
||
1280 |
commentStringsForMimeType:mime suffix:suff |
|
1281 |
"return a useful comment definition; heuristics for now. |
|
1282 |
The returned value is an array of 2 elements; |
|
1283 |
the first is the end-of-line comment string (or nil); |
|
1284 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1285 |
||
1286 |
^ self |
|
1287 |
commentStringsForMimeType:mime suffix:suff |
|
1288 |
ifUnknown: #(';' (nil nil)) |
|
1289 |
||
1290 |
" |
|
1291 |
|mime| |
|
1292 |
||
1293 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1294 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1295 |
" |
|
1296 |
||
1297 |
" |
|
1298 |
|mime| |
|
1299 |
||
1300 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1301 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1302 |
" |
|
1303 |
! |
|
1304 |
||
1305 |
commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString |
|
1306 |
"return a useful comment definition; heuristics for now. |
|
1307 |
The returned value is an array of 2 elements; |
|
1308 |
the first is the end-of-line comment string (or nil); |
|
1309 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1310 |
||
1311 |
|commentSpec| |
|
1312 |
||
1313 |
commentSpec := TypeToCommentStringMapping at:mime ifAbsent:nil. |
|
1314 |
commentSpec notNil ifTrue:[ |
|
1315 |
^ commentSpec |
|
1316 |
]. |
|
1317 |
||
1318 |
commentSpec := SuffixToCommentStringMapping at:suff ifAbsent:nil. |
|
1319 |
commentSpec notNil ifTrue:[ |
|
1320 |
^ commentSpec |
|
1321 |
]. |
|
1322 |
||
1323 |
^ alternativeBlockReturningCommentString value |
|
1324 |
||
1325 |
" |
|
1326 |
|mime| |
|
1327 |
||
1328 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1329 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1330 |
" |
|
1331 |
||
1332 |
" |
|
1333 |
|mime| |
|
1334 |
||
1335 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1336 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1337 |
" |
|
2298 | 1338 |
! |
1339 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1340 |
parenthesisSpecForFilename:aFilename |
2298 | 1341 |
"return a useful parentesis spec; heuristics for now. |
1342 |
The returned value is a dictionary to be used as parentesis spec in an editor" |
|
1343 |
||
1344 |
|mime| |
|
1345 |
||
1346 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1347 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) |
2298 | 1348 |
|
1349 |
" |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1350 |
MIMETypes parenthesisSpecForFilename:'Object.st'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1351 |
MIMETypes parenthesisSpecForFilename:'Foo.java'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1352 |
MIMETypes parenthesisSpecForFilename:'Foo.html'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1353 |
MIMETypes parenthesisSpecForFilename:'Foo.lsp'. |
2298 | 1354 |
" |
1355 |
||
1356 |
"Created: / 10-04-2007 / 15:18:41 / cg" |
|
1357 |
! |
|
1358 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1359 |
parenthesisSpecForFilename:aFilename ifUnknown:alternative |
2298 | 1360 |
|mime| |
1361 |
||
1362 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1363 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternative |
2298 | 1364 |
|
1365 |
"Created: / 10-04-2007 / 15:26:20 / cg" |
|
1366 |
! |
|
1367 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1368 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1369 |
^ self |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1370 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1371 |
ifUnknown: nil |
1372 |
||
1373 |
"Created: / 10-04-2007 / 15:19:39 / cg" |
|
1374 |
! |
|
1375 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1376 |
parenthesisSpecForMimeType:mime suffix:suff ifUnknown:alternativeValue |
2298 | 1377 |
|spec| |
1378 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1379 |
spec := TypeToParenthesisSpecMapping at:mime ifAbsent:nil. |
2298 | 1380 |
spec notNil ifTrue:[ |
1381 |
^ spec |
|
1382 |
]. |
|
1383 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1384 |
spec := SuffixToParenthesisSpecMapping at:suff ifAbsent:nil. |
2298 | 1385 |
spec notNil ifTrue:[ |
1386 |
^ spec |
|
1387 |
]. |
|
1388 |
||
1389 |
^ alternativeValue value |
|
1390 |
||
1391 |
"Created: / 10-04-2007 / 15:20:38 / cg" |
|
1729 | 1392 |
! ! |
1393 |
||
1612 | 1394 |
!MIMETypes::MIMEType class methodsFor:'documentation'! |
1395 |
||
1396 |
documentation |
|
1397 |
" |
|
1864 | 1398 |
like a string, but knows that it represents a mimeType. |
3359 | 1399 |
mimetypes are singletons, remembered in the class variable CachedTypes. |
1612 | 1400 |
" |
1401 |
! ! |
|
1402 |
||
1403 |
!MIMETypes::MIMEType class methodsFor:'instance creation'! |
|
1404 |
||
1405 |
fromString:aString |
|
1406 |
|cachedType newType| |
|
1407 |
||
1408 |
aString class == self ifTrue:[^ aString]. |
|
1409 |
||
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1410 |
CachedTypes isNil ifTrue:[ |
3012 | 1411 |
CachedTypes := Dictionary new:100. |
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1412 |
]. |
1612 | 1413 |
cachedType := CachedTypes at:aString ifAbsent:nil. |
1414 |
cachedType notNil ifTrue:[^ cachedType]. |
|
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1415 |
|
1612 | 1416 |
newType := aString copy changeClassTo:self. |
1417 |
CachedTypes at:aString put:newType. |
|
1418 |
^ newType |
|
1419 |
||
1420 |
" |
|
1421 |
self fromString:'text/html' |
|
1422 |
" |
|
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1423 |
|
3012 | 1424 |
"Modified: / 20-07-2012 / 17:36:31 / cg" |
1612 | 1425 |
! ! |
1426 |
||
1427 |
!MIMETypes::MIMEType methodsFor:'queries'! |
|
1428 |
||
3359 | 1429 |
fileTypeInfo |
1430 |
^ MIMETypes fileTypeInfoForMimeType:self |
|
1431 |
||
1432 |
" |
|
1433 |
(MIMETypes mimeTypeFromString:'application/x-smalltalk-source') fileTypeInfo |
|
1434 |
" |
|
1435 |
! |
|
1436 |
||
1693 | 1437 |
isArchive |
3260 | 1438 |
<resource: #obsolete> |
1439 |
"return true, if I represent an archive type (such as zip or tar)" |
|
1440 |
||
1441 |
^ self isArchiveType |
|
1442 |
! |
|
1443 |
||
1444 |
isArchiveType |
|
1864 | 1445 |
"return true, if I represent an archive type (such as zip or tar)" |
1446 |
||
1612 | 1447 |
|archivTypes| |
1448 |
||
1729 | 1449 |
archivTypes := MIMETypes applicationCompressorsAndArchiveTypeList. |
1612 | 1450 |
archivTypes pairWiseDo:[: ext : type | |
1451 |
self = type ifTrue:[ ^ true]. |
|
1452 |
]. |
|
1453 |
^ false |
|
1454 |
! |
|
1455 |
||
2024 | 1456 |
isBinary |
3260 | 1457 |
<resource: #obsolete> |
1458 |
"return true, if I represent a binary (non-text) type" |
|
1459 |
||
1460 |
^ self isBinaryType |
|
1461 |
! |
|
1462 |
||
1463 |
isBinaryType |
|
2024 | 1464 |
"return true, if I represent a binary (non-text) type" |
1465 |
||
1466 |
^ self isTextType not |
|
1467 |
! |
|
1468 |
||
1612 | 1469 |
isHtml |
3260 | 1470 |
<resource: #obsolete> |
1471 |
"return true, if I represent the html text type" |
|
1472 |
||
1473 |
^ self isHtmlType |
|
1474 |
! |
|
1475 |
||
1476 |
isHtmlType |
|
1864 | 1477 |
"return true, if I represent the html text type" |
1612 | 1478 |
|
1479 |
^ (self = 'text/html') |
|
1480 |
! |
|
1481 |
||
1482 |
isImage |
|
3260 | 1483 |
<resource: #obsolete> |
1484 |
"return true, if I represent an image type (such as gif or jpg)" |
|
1485 |
||
1486 |
^ self isImageType |
|
1487 |
! |
|
1488 |
||
1489 |
isImageType |
|
1864 | 1490 |
"return true, if I represent an image type (such as gif or jpg)" |
1612 | 1491 |
|
1693 | 1492 |
^ (self startsWith:'image/') |
1612 | 1493 |
! |
1494 |
||
1495 |
isPdf |
|
3260 | 1496 |
<resource: #obsolete> |
1497 |
"return true, if I represent the pdf type" |
|
1498 |
||
1499 |
^ self isPdfType |
|
1500 |
! |
|
1501 |
||
1502 |
isPdfType |
|
1864 | 1503 |
"return true, if I represent the pdf type" |
1504 |
||
1612 | 1505 |
^ (self = 'application/pdf') |
1506 |
! |
|
1507 |
||
1508 |
isSmalltalkSource |
|
3260 | 1509 |
<resource: #obsolete> |
1510 |
"return true, if I represent the smalltalk sourcecode type" |
|
1511 |
||
1512 |
^ self isSmalltalkSourceType |
|
1513 |
! |
|
1514 |
||
1515 |
isSmalltalkSourceType |
|
1864 | 1516 |
"return true, if I represent the smalltalk sourcecode type" |
1517 |
||
3359 | 1518 |
^ (self startsWith: 'application/x-smalltalk-source') |
1783 | 1519 |
! |
1520 |
||
2024 | 1521 |
isTextType |
1522 |
"return true, if I represent some text type" |
|
1523 |
||
1524 |
^ self startsWith:'text/' |
|
1525 |
! |
|
1526 |
||
1783 | 1527 |
isXml |
3260 | 1528 |
<resource: #obsolete> |
1529 |
"return true, if I represent the xml text type" |
|
1530 |
||
1531 |
^ self isXmlType |
|
1532 |
! |
|
1533 |
||
1534 |
isXmlType |
|
1864 | 1535 |
"return true, if I represent the xml text type" |
1536 |
||
1783 | 1537 |
^ (self = 'text/xml') |
2490 | 1538 |
! |
1539 |
||
1540 |
suffix |
|
1541 |
^ MIMETypes suffixForMimeType:self |
|
1542 |
||
1543 |
" |
|
1544 |
(MIMETypes mimeTypeFromString:'application/x-expecco-testsuite') suffix |
|
1545 |
" |
|
643 | 1546 |
! ! |
1547 |
||
1548 |
!MIMETypes class methodsFor:'documentation'! |
|
1549 |
||
1550 |
version |
|
3359 | 1551 |
^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.135 2014-07-10 19:45:59 cg Exp $' |
2758
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
1552 |
! |
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
1553 |
|
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
1554 |
version_CVS |
3359 | 1555 |
^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.135 2014-07-10 19:45:59 cg Exp $' |
643 | 1556 |
! ! |
1666 | 1557 |
|
3104 | 1558 |
|
643 | 1559 |
MIMETypes initialize! |