NonPositionableExternalStream.st
changeset 22954 7a042f543d73
parent 22777 8edae1451af4
child 23485 aecf0f68402c
equal deleted inserted replaced
22953:3b0587838bd3 22954:7a042f543d73
   448     (position isNil or:[newPosition < position]) ifTrue:[
   448     (position isNil or:[newPosition < position]) ifTrue:[
   449         "there is no turning back"
   449         "there is no turning back"
   450         ^ self positionError
   450         ^ self positionError
   451     ].
   451     ].
   452     self skip:newPosition - position.
   452     self skip:newPosition - position.
       
   453 !
       
   454 
       
   455 setToEnd
       
   456     "skip to the end of stream."
       
   457 
       
   458     [self nextOrNil notNil] whileTrue.
       
   459 
       
   460     "Created: / 18-05-2018 / 14:07:36 / Stefan Vogel"
   453 !
   461 !
   454 
   462 
   455 skip:numberToSkip
   463 skip:numberToSkip
   456     "skip count bytes/characters, return the receiver.
   464     "skip count bytes/characters, return the receiver.
   457      Re-redefined since PositionableStream redefined it."
   465      Re-redefined since PositionableStream redefined it."
   769 
   777 
   770     answerStream := WriteStream on:(String uninitializedNew:80).
   778     answerStream := WriteStream on:(String uninitializedNew:80).
   771     [
   779     [
   772         "#atEnd waits for new data or EOF"
   780         "#atEnd waits for new data or EOF"
   773         self atEnd ifTrue:[
   781         self atEnd ifTrue:[
   774             answerStream size == 0 ifTrue:[
   782             answerStream isEmpty ifTrue:[
   775                 ^ self pastEndRead.
   783                 ^ self pastEndRead.
   776             ].
   784             ].
   777             ^ answerStream contents.
   785             ^ answerStream contents.
   778         ].
   786         ].
   779         available := self numAvailableForRead.
   787         available := self numAvailableForRead.
   786         wasBinary := binary.            "temporarily set to text mode"
   794         wasBinary := binary.            "temporarily set to text mode"
   787         binary := false.
   795         binary := false.
   788         available timesRepeat:[
   796         available timesRepeat:[
   789             char := super nextOrNil.         "don't wait - we know that there is data"
   797             char := super nextOrNil.         "don't wait - we know that there is data"
   790             char == Character cr ifTrue:[
   798             char == Character cr ifTrue:[
   791                 (answerStream size ~~ 0 and:[answerStream last == Character return]) ifTrue:[
   799                 (answerStream isEmpty not and:[answerStream last == Character return]) ifTrue:[
   792                     answerStream backStep.
   800                     answerStream backStep.
   793                 ].
   801                 ].
   794                 binary := wasBinary.
   802                 binary := wasBinary.
   795                 ^ answerStream contents.
   803                 ^ answerStream contents.
   796             ].
   804             ].
   800         ].
   808         ].
   801         binary := wasBinary.            "restore saved mode"
   809         binary := wasBinary.            "restore saved mode"
   802     ] loop.
   810     ] loop.
   803 
   811 
   804     "not reached"
   812     "not reached"
       
   813 
       
   814     "Modified: / 18-05-2018 / 14:01:19 / Stefan Vogel"
   805 !
   815 !
   806 
   816 
   807 nextOrNil
   817 nextOrNil
   808     "like #next, this returns the next element, if available.
   818     "like #next, this returns the next element, if available.
   809      If nothing is available, this does never raise a read-beyond end signal.
   819      If nothing is available, this does never raise a read-beyond end signal.