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