ResourcePack.st
changeset 5781 fc35ed4fd223
parent 5653 0e2dd1102337
child 5826 c4ed474970c1
equal deleted inserted replaced
5780:7acd722f9cf9 5781:fc35ed4fd223
  1174     "read definitions from a file in a directory"
  1174     "read definitions from a file in a directory"
  1175 
  1175 
  1176     |inStream ok|
  1176     |inStream ok|
  1177 
  1177 
  1178     fileReadFailed := false.
  1178     fileReadFailed := false.
  1179     dirName = 'resources' ifTrue:[
  1179     "/ need to catch errors here, as the handler might itself need resources.
  1180         inStream := Smalltalk resourceFileStreamFor:fileName
  1180     "/ (happens when da.rs is not present in libbasic/resources.rs)
  1181     ] ifFalse:[
  1181     ExternalStream openErrorSignal handle:[:ex |
  1182         inStream := Smalltalk 
  1182         Transcript showCR:'ResourcePack: failed to open file: ',fileName asString,' in ',dirName asString.
  1183                         systemFileStreamFor:(dirName 
  1183         inStream := nil.
  1184                                                 isNil ifTrue:[fileName]
  1184     ] do:[
  1185                                                 ifFalse:[dirName asFilename construct:fileName]).
  1185         dirName = 'resources' ifTrue:[
  1186     ].
  1186             inStream := Smalltalk resourceFileStreamFor:fileName
       
  1187         ] ifFalse:[
       
  1188             inStream := Smalltalk systemFileStreamFor:
       
  1189                             (dirName isNil 
       
  1190                                 ifTrue:[fileName]
       
  1191                                 ifFalse:[dirName asFilename construct:fileName]).
       
  1192         ].
       
  1193     ].
       
  1194 
  1187     inStream isNil ifTrue:[
  1195     inStream isNil ifTrue:[
  1188         "
  1196         "
  1189          an empty pack
  1197          an empty pack
  1190         "
  1198         "
  1191         ^ self nonexistingFileRead
  1199         ^ self nonexistingFileRead
  1198         fileReadFailed := true.
  1206         fileReadFailed := true.
  1199 
  1207 
  1200         ('ResourcePack [warning]: ''' , inStream pathName , ''' contains error(s) - data may be incomplete.') errorPrintCR.
  1208         ('ResourcePack [warning]: ''' , inStream pathName , ''' contains error(s) - data may be incomplete.') errorPrintCR.
  1201     ].
  1209     ].
  1202 
  1210 
  1203     "Modified: / 19-10-2006 / 22:46:48 / cg"
  1211     "Modified: / 20-08-2011 / 17:10:02 / cg"
  1204 !
  1212 !
  1205 
  1213 
  1206 readFromResourceStream:inStream in:dirName
  1214 readFromResourceStream:inStream in:dirName
  1207     "read definitions from a stream. The dirName argument is required to
  1215     "read definitions from a stream. The dirName argument is required to
  1208      specify where #include files are searched for.
  1216      specify where #include files are searched for.
  1388 ! !
  1396 ! !
  1389 
  1397 
  1390 !ResourcePack class methodsFor:'documentation'!
  1398 !ResourcePack class methodsFor:'documentation'!
  1391 
  1399 
  1392 version
  1400 version
  1393     ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.148 2010-11-13 10:42:05 cg Exp $'
  1401     ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.149 2011-08-20 15:13:07 cg Exp $'
  1394 !
  1402 !
  1395 
  1403 
  1396 version_CVS
  1404 version_CVS
  1397     ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.148 2010-11-13 10:42:05 cg Exp $'
  1405     ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.149 2011-08-20 15:13:07 cg Exp $'
  1398 ! !
  1406 ! !
  1399 
  1407 
  1400 ResourcePack initialize!
  1408 ResourcePack initialize!