PositionableStream.st
changeset 6923 6fff585a17cb
parent 6922 b7cd10d26d99
child 6924 e6bdcfc147e1
equal deleted inserted replaced
6922:b7cd10d26d99 6923:6fff585a17cb
   374 
   374 
   375 fileIn
   375 fileIn
   376     "file in from the receiver, i.e. read chunks and evaluate them -
   376     "file in from the receiver, i.e. read chunks and evaluate them -
   377      return the value of the last chunk."
   377      return the value of the last chunk."
   378 
   378 
   379     |oldPath val|
   379     |oldPath val notifiedLoader|
       
   380 
       
   381     SourceFileLoader notNil ifTrue:[
       
   382         notifiedLoader := SourceFileLoader on:self.
       
   383     ].
   380 
   384 
   381     self isFileStream ifFalse:[
   385     self isFileStream ifFalse:[
   382         ^ self fileInNotifying:(SourceFileLoader on:self) passChunk:true.
   386         ^ self fileInNotifying:notifiedLoader passChunk:true.
   383     ].
   387     ].
   384 
   388 
   385     [   |thisDirectory|
   389     [   |thisDirectory|
   386 
   390 
   387         oldPath := Smalltalk systemPath.
   391         oldPath := Smalltalk systemPath.
   388         thisDirectory := self pathName asFilename directory.
   392         thisDirectory := self pathName asFilename directory.
   389         Smalltalk systemPath:(oldPath copy addFirst:thisDirectory pathName; yourself).
   393         Smalltalk systemPath:(oldPath copy addFirst:thisDirectory pathName; yourself).
   390         CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[
   394         CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[
   391             SourceFileLoader isNil ifTrue:[
   395             val := self fileInNotifying:notifiedLoader passChunk:true.
   392                 val := self fileInNotifying:nil passChunk:true.
       
   393             ] ifFalse:[
       
   394                 val := self fileInNotifying:(SourceFileLoader on:self) passChunk:true.
       
   395             ]
       
   396         ]
   396         ]
   397     ] ensure:[
   397     ] ensure:[
   398         Smalltalk systemPath:oldPath.
   398         Smalltalk systemPath:oldPath.
   399     ].
   399     ].
   400     ^ val
   400     ^ val
   467         However, other than methodsFor expressions are possible - you can
   467         However, other than methodsFor expressions are possible - you can
   468         (in theory) create readers for any syntax.
   468         (in theory) create readers for any syntax.
   469     "
   469     "
   470 
   470 
   471     |aString sawExcla rslt done|
   471     |aString sawExcla rslt done|
       
   472 
       
   473     Smalltalk::Compiler isNil ifTrue:[
       
   474         self isFileStream ifTrue:[
       
   475             Transcript show:('[' , self pathName , '] ').
       
   476         ].
       
   477         Transcript showCR:'cannot fileIn (no compiler).'.
       
   478         ^ nil.
       
   479     ].
   472 
   480 
   473     self skipSeparators.
   481     self skipSeparators.
   474     self atEnd ifFalse:[
   482     self atEnd ifFalse:[
   475         sawExcla := self peekFor:(self class chunkSeparator).
   483         sawExcla := self peekFor:(self class chunkSeparator).
   476         aString := self nextChunk.
   484         aString := self nextChunk.
  1139 ! !
  1147 ! !
  1140 
  1148 
  1141 !PositionableStream class methodsFor:'documentation'!
  1149 !PositionableStream class methodsFor:'documentation'!
  1142 
  1150 
  1143 version
  1151 version
  1144     ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.117 2002-12-06 14:32:45 penk Exp $'
  1152     ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.118 2002-12-06 14:37:49 penk Exp $'
  1145 ! !
  1153 ! !
  1146 
  1154 
  1147 PositionableStream initialize!
  1155 PositionableStream initialize!