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