MIMETypes.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Dec 1999 22:29:34 +0100
changeset 1300 09ff1f28470c
parent 1275 cf421c7dfeec
child 1311 2a297e71602c
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG 
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
Object subclass:#MIMETypes
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	instanceVariableNames:''
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:'TypeToImageReaderClassMapping FileSuffixToTypeMapping
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
    18
		FilenameToTypeMapping FileSuffixToImageReaderClassMapping
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
    19
		CharSetToFontMapping LastSuffix LastType'
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	category:'System-Documentation'
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!MIMETypes class methodsFor:'documentation'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
copyright
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 COPYRIGHT (c) 1997 by eXept Software AG 
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
	      All Rights Reserved
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 This software is furnished under a license and may be used
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 only in accordance with the terms of that license and with the
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 be provided or otherwise made available to, or used by, any
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 other person.  No title to or ownership of the software is
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 hereby transferred.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
documentation
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    just a place to keep MIME information
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    (avoid spreading things at many places)
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    47
    MIMETypes is abstract and functional.
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    48
    Actually, in some OperatingSystems, this information may
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    49
    be found in some config files (or registries).
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    50
    Therefore, this class may have to be extended to support this
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    51
    and fetch the information from there eventually.
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    52
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    [author:]
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        Claus Gittinger
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!MIMETypes class methodsFor:'initialization'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
initialize
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
    61
    "initialize wellKnown facts"
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
    62
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    63
    |typeToImageReaderClassMapping fileSuffixToTypeMapping
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    64
     fileSuffixToImageReaderClassMapping charSetToFontMapping|
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
    65
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    66
    (fileSuffixToImageReaderClassMapping := FileSuffixToImageReaderClassMapping) isNil ifTrue:[
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    67
        FileSuffixToImageReaderClassMapping := fileSuffixToImageReaderClassMapping := Dictionary new
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    68
    ].
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    69
    (typeToImageReaderClassMapping := TypeToImageReaderClassMapping) isNil ifTrue:[
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    70
        TypeToImageReaderClassMapping := typeToImageReaderClassMapping := Dictionary new
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
    71
    ].
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    72
    (fileSuffixToTypeMapping := FileSuffixToTypeMapping) isNil ifTrue:[
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    73
        FileSuffixToTypeMapping := fileSuffixToTypeMapping := Dictionary new
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    74
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    75
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    76
    "/ setup file-suffix to mimeType mapping ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    77
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    78
    #(
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    79
        "/ image formats ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    80
1216
26fe79e724d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1188
diff changeset
    81
        ('jpg' 'jpeg')  'image/jpeg'
1188
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    82
        'gif'           'image/gif'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    83
        ('tif' 'tiff')  'image/tiff'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    84
        'xbm'           'image/x-xbitmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    85
        'xpm'           'image/x-xpixmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    86
        'png'           'image/x-png'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    87
        'pcd'           'image/x-photo-cd'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    88
        'bmp'           'image/x-MS-bmp'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    89
        'rgb'           'image/x-rgb'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    90
        'ppm'           'image/x-portable-pixmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    91
        'pgm'           'image/x-portable-graymap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    92
        'pbm'           'image/x-portable-bitmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    93
        'pnm'           'image/x-portable-anymap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    94
        'xwd'           'image/x-xwindowdump'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
    95
        'ras'           'image/x-cmu-raster'
1216
26fe79e724d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1188
diff changeset
    96
        'tga'           'image/x-targa'
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    97
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    98
        "/ misc text ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
    99
1221
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   100
        ('htm' 'html')          'text/html'
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   101
        ('txt' 'text')          'text/plain'
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   102
1221
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   103
        ('ps' 'eps')            'application/postscript'
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   104
        'pdf'                   'application/pdf'
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   105
        'rtf'                   'application/rtf'
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   106
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   107
        "/ video formats ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   108
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   109
        'movie'                            'video/x-sgi-movie'
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   110
        'avi'                              'video/x-msvideo'
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   111
        ('qt' 'mov' 'moov')                'video/quicktime'
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   112
        ('mpv2' 'mp2v' 'mp2' 'mpeg2')      'video/x-mpeg2'
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   113
        ('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg'
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   114
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   115
        "/ audio formats ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   116
1221
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   117
        ('ra' 'ram')            'audio/x-pn-realaudio'
1188
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   118
        ('mpa' 'mpega')         'audio/x-mpeg'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   119
        'wav'                   'audio/x-wav'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   120
        ('aif' 'aiff' 'aifc')   'audio/x-aiff'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   121
        ('au' 'snd')            'audio/basic'
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   122
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   123
        "/ misc stuff
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   124
1221
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   125
        "/ progr. languages
1274
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   126
        'st'                         'application/x-smalltalk-source'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   127
        'c'                          'application/x-c-source'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   128
        ('cc' 'cpp')                 'application/x-cpp-source'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   129
        ('js' 'mocha')               'application/x-javascript'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   130
        ('java' 'jav')               'application/x-java-source'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   131
        'sh'                         'application/x-sh'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   132
        'csh'                        'application/x-csh'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   133
        'tcl'                        'application/x-tcl'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   134
        'pl'                         'application/x-perl'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   135
        'mak'                        'application/x-make'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   136
        'bat'                        'application/x-batch-script'
4b7fe76f7243 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   137
        ('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source'
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   138
1221
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   139
        "/ compressors / archivers
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   140
        'tar'                   'application/x-tar'
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   141
        'gtar'                  'application/x-gtar'
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   142
        'tgz'                   'application/x-tar-compressed'
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   143
        'zip'                   'application/x-zip-compressed'
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   144
        'cpio'                  'application/x-cpio'
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   145
        'shar'                  'application/x-shar'
1436ca154fe0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
   146
        'jar'                   'application/java-archive'
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   147
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   148
    ) pairWiseDo:[:suff :type|
1188
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   149
        suff isArray ifTrue:[
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   150
            suff do:[:s | fileSuffixToTypeMapping at:s put:type]
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   151
        ] ifFalse:[
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   152
            fileSuffixToTypeMapping at:suff put:type
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   153
        ]
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   154
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   155
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   156
    FilenameToTypeMapping := Dictionary new.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   157
    #(
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   158
        ('makefile' 'make.proto')  'application/x-make'
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   159
    ) pairWiseDo:[:nm :type|
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   160
        nm isArray ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   161
            nm do:[:s | FilenameToTypeMapping at:s put:type]
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   162
        ] ifFalse:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   163
            FilenameToTypeMapping at:nm put:type
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   164
        ]
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   165
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   166
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   167
    "/ setup mimeType to image reader class mapping ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   168
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   169
    typeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   170
    typeToImageReaderClassMapping at:'image/gif'  put:GIFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   171
    typeToImageReaderClassMapping at:'image/tiff' put:TIFFReader.
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   172
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   173
    "/ setup suffix to image reader class mapping ...
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   174
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   175
    fileSuffixToImageReaderClassMapping at:'jpg'  put:JPEGReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   176
    fileSuffixToImageReaderClassMapping at:'gif'  put:GIFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   177
    fileSuffixToImageReaderClassMapping at:'tif'  put:TIFFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   178
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   179
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   180
    "/ character sets (not really mime stuff, but also placed here)
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   181
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   182
    (charSetToFontMapping := CharSetToFontMapping) isNil ifTrue:[
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   183
        CharSetToFontMapping := charSetToFontMapping := Dictionary new
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   184
    ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   185
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   186
    #(
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   187
        'iso2022-jp'   'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   188
        'x-iso2022-jp' 'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   189
        'x-euc-jp'     'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   190
        'x-shift-jis'  'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   191
        'x-sjis'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   192
        'x-jis7'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   193
        'jis7'         'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   194
        'euc'          'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   195
        'euc-jp'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   196
        'sjis'         'jis*0208*'
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   197
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   198
        'big5'         'big5*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   199
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   200
        'gb2312'       'gb*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   201
        'hz-gb-2312'   'gb*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   202
        'x-gbk'        'gb*'
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   203
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   204
        'iso2022-kr'   'ksc*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   205
        'x-euc-kr'     'ksc*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   206
    ) pairWiseDo:[:charSet :fontEncoding|
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   207
         charSetToFontMapping at:charSet put:fontEncoding
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   208
    ].
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    "
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
     self initialize
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    "
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
1269
4362ec6dd5c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
   214
    "Modified: / 19.11.1999 / 15:01:53 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
!MIMETypes class methodsFor:'accessing'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   219
defineImageType:mimeType suffix:aSuffix reader:aReaderClass
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   220
    "register an image reader."
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   221
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   222
    aSuffix notNil ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   223
        self imageReaderForSuffix:aSuffix put:aReaderClass.
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   224
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   225
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   226
    mimeType notNil ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   227
        self imageReaderForType:mimeType put:aReaderClass
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   228
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   229
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   230
    (aSuffix notNil and:[mimeType notNil]) ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   231
        self mimeTypeForSuffix:aSuffix put:mimeType
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   232
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   233
!
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   234
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
fileSuffixToImageReaderMapping
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   236
    "return the suffix-to-imageReader mapping"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   237
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    ^ FileSuffixToImageReaderClassMapping ? #()
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   240
    "Modified: / 1.8.1998 / 17:00:11 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   243
fontForCharset:aCharSet
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   244
    "return the font-encoding for an iso-charset"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   245
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   246
    ^ CharSetToFontMapping at:aCharSet ifAbsent:nil
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   247
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   248
    "
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   249
     MIMETypes fontForCharset:'iso2022-jp'       
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   250
     MIMETypes fontForCharset:'euc-jp'     
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   251
    "
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   252
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   253
    "Modified: / 1.8.1998 / 17:00:57 / cg"
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   254
!
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   255
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
imageFileSuffixes
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   257
    "return a collection with known file suffixes"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   258
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    ^ FileSuffixToImageReaderClassMapping keys
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   262
    "Created: / 30.6.1997 / 22:04:48 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   263
    "Modified: / 1.8.1998 / 17:01:26 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
imageReaderClasses
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   267
    "return a collection of registered image reader classes"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   268
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   269
    |setOfClasses|
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   270
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   271
    setOfClasses := IdentitySet new.
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   272
    FileSuffixToImageReaderClassMapping notNil ifTrue:[
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   273
        FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   274
            setOfClasses add:cls
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   275
        ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   276
    ].
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   277
    TypeToImageReaderClassMapping notNil ifTrue:[
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   278
        TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   279
            setOfClasses add:cls
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   280
        ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   281
    ].
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   282
    ^ setOfClasses
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   284
    "Created: / 30.6.1997 / 22:03:42 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   285
    "Modified: / 1.8.1998 / 16:59:52 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
imageReaderForSuffix:aSuffix
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   289
    "given a file suffix, return an approriate image reader class"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   290
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    ^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   294
    "Created: / 30.6.1997 / 21:59:11 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   295
    "Modified: / 1.8.1998 / 17:01:58 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
imageReaderForSuffix:aSuffix put:aReaderClass
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   299
    "register an image reader for a file suffix"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   300
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
    FileSuffixToImageReaderClassMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
        FileSuffixToImageReaderClassMapping := Dictionary new.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   306
    "Created: / 30.6.1997 / 21:59:43 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   307
    "Modified: / 1.8.1998 / 17:02:14 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
imageReaderForType:mimeTypeString
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   311
    "given a mime-type, return an approriate image reader class"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   312
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
    TypeToImageReaderClassMapping isNil ifTrue:[^ nil].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
    ^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   316
    "Created: / 30.6.1997 / 21:56:01 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   317
    "Modified: / 1.8.1998 / 17:02:28 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
imageReaderForType:mimeTypeString put:aReaderClass
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   321
    "register an image reader for a mime-type"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   322
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
    TypeToImageReaderClassMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
        TypeToImageReaderClassMapping := Dictionary new.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   328
    "Created: / 30.6.1997 / 21:56:11 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   329
    "Modified: / 1.8.1998 / 17:02:40 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   332
mimeTypeForFilename:filename
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   333
    "given a filename, return the mime-type or nil, if unknown"
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   334
1273
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   335
    |type lcFilename suff|
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   336
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   337
    lcFilename := filename asFilename name asLowercase.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   338
    type := FilenameToTypeMapping at:lcFilename ifAbsent:nil.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   339
    type isNil ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   340
        "/ allow for fallback ...
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   341
        type := OperatingSystem mimeTypeForFilename:lcFilename.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   342
        "/ 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
   343
        "/ 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
   344
        "/ the OS.
1275
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   345
"/        type isNil ifTrue:[
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   346
"/            FilenameToTypeMapping at:lcFilename put:#unknown
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   347
"/        ].
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   348
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   349
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   350
    type == #unknown ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   351
        type := nil.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   352
    ].
1273
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   353
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   354
    type isNil ifTrue:[
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   355
        suff := filename asFilename suffix.
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   356
        suff size ~~ 0 ifTrue:[
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   357
            ^ self mimeTypeForSuffix:suff
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   358
        ]
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   359
    ].
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   360
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   361
    ^ type
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   362
!
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   363
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   364
mimeTypeForFilename:filename put:mimeType
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   365
    "register a mime type for a filename"
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   366
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   367
    FilenameToTypeMapping isNil ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   368
        FilenameToTypeMapping := Dictionary new
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   369
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   370
    FilenameToTypeMapping at:filename put:mimeType asLowercase
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   371
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   372
!
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   373
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
mimeTypeForSuffix:suffix
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   375
    "given a file suffix, return the mime-type"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   376
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   377
    |type lcSuffix|
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   378
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   379
    lcSuffix := suffix asLowercase.
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   380
    lcSuffix = LastSuffix ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   381
        type := LastType
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   382
    ] ifFalse:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   383
        type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   384
        type isNil ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   385
            "/ allow for fallback ...
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   386
            type := OperatingSystem mimeTypeForSuffix:lcSuffix.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   387
            "/ the special value #unknown is returned as nil;
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   388
            "/ this avoids constant retry if a mimeType is not known in
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   389
            "/ the OS.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   390
    "/        type isNil ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   391
    "/            FileSuffixToTypeMapping at:lcSuffix put:#unknown
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   392
    "/        ].
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   393
        ].
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   394
        LastSuffix := lcSuffix.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   395
        LastType := type.
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   396
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   397
    type == #unknown ifTrue:[
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   398
        type := nil
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   399
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   400
    ^ type
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   402
    "Created: / 30.6.1997 / 21:55:51 / cg"
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   403
    "Modified: / 23.12.1999 / 22:30:55 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
mimeTypeForSuffix:suffix put:mimeType
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   407
    "register a mime type for a file suffix"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   408
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
    FileSuffixToTypeMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
        FileSuffixToTypeMapping := Dictionary new
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
    FileSuffixToTypeMapping at:suffix put:mimeType asLowercase
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   414
    "Created: / 30.6.1997 / 21:56:20 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   415
    "Modified: / 1.8.1998 / 17:03:18 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
!MIMETypes class methodsFor:'documentation'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
version
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   421
    ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.23 1999-12-23 21:29:34 cg Exp $'
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
MIMETypes initialize!