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