NonPositionableExternalStream.st
branchjv
changeset 20728 83c74234945e
parent 20727 fb8c5591428b
parent 20685 4cf48622d541
child 21024 8734987eb5c7
equal deleted inserted replaced
20727:fb8c5591428b 20728:83c74234945e
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
   201 buffered:aBoolean
   203 buffered:aBoolean
   202     "do not allow to change to buffered mode - ignore true here"
   204     "do not allow to change to buffered mode - ignore true here"
   203 
   205 
   204     aBoolean ifFalse:[
   206     aBoolean ifFalse:[
   205 	super buffered:false.
   207 	super buffered:false.
   206     ].
       
   207 ! !
       
   208 
       
   209 !NonPositionableExternalStream methodsFor:'closing'!
       
   210 
       
   211 close
       
   212     "Close the stream.
       
   213      No error if the stream is not open."
       
   214 
       
   215     |semasToSignal|
       
   216 
       
   217     self isOpen ifTrue:[
       
   218         "make sure, that no select is performed on closed file descriptors"
       
   219         semasToSignal := Processor disableFd:self fileHandle doSignal:false.
       
   220         super close.
       
   221         "tell the waiters that they must not wait any longer"
       
   222         semasToSignal do:[:eachSema|
       
   223             eachSema signalForAll.
       
   224         ].
       
   225     ].
   208     ].
   226 ! !
   209 ! !
   227 
   210 
   228 !NonPositionableExternalStream methodsFor:'error handling'!
   211 !NonPositionableExternalStream methodsFor:'error handling'!
   229 
   212 
   419 	^ self printOn:aStream
   402 	^ self printOn:aStream
   420     ].
   403     ].
   421     super storeOn:aStream
   404     super storeOn:aStream
   422 ! !
   405 ! !
   423 
   406 
       
   407 !NonPositionableExternalStream protectedMethodsFor:'private'!
       
   408 
       
   409 closeFile
       
   410     |semasToSignal|
       
   411 
       
   412     handle notNil ifTrue:[
       
   413         "make sure, that no select is performed on closed file descriptors"
       
   414         semasToSignal := Processor disableFd:self fileHandle doSignal:false.
       
   415         super closeFile.
       
   416 
       
   417         "tell the waiters that they must not wait any longer"
       
   418         semasToSignal do:[:eachSema|
       
   419             eachSema signalForAll.
       
   420         ].
       
   421     ].
       
   422 ! !
       
   423 
   424 !NonPositionableExternalStream methodsFor:'private'!
   424 !NonPositionableExternalStream methodsFor:'private'!
   425 
   425 
   426 handleForStderr
   426 handleForStderr
   427     "{ Pragma: +optSpace }"
   427     "{ Pragma: +optSpace }"
   428 
   428 
   547         OperatingSystem hasConsole ifFalse:[
   547         OperatingSystem hasConsole ifFalse:[
   548             ^ true
   548             ^ true
   549         ]
   549         ]
   550     ].
   550     ].
   551 
   551 
   552     "first, wait to avoid blocking on the read.
   552     handle notNil ifTrue:[
   553      On end of stream or error, readWait will return"
   553         "first, wait to avoid blocking on the read.
   554 
   554          On end of stream or error, readWait will return"
   555     self readWaitWithTimeoutMs:nil.
   555 
       
   556         self readWaitWithTimeoutMs:nil.
       
   557     ].
   556     handle isNil ifTrue:[
   558     handle isNil ifTrue:[
   557         "we were closed while waiting - so we are at the end"
   559         "we are closed or were closed while waiting - so we are at the end"
   558         ^ true.
   560         ^ true.
   559     ].
   561     ].
   560     ^ super atEnd.
   562     ^ super atEnd.
   561 !
   563 !
   562 
   564 
   650      If nothing is available, this does never raise a read-beyond end signal.
   652      If nothing is available, this does never raise a read-beyond end signal.
   651      Instead, nil is returned immediately.
   653      Instead, nil is returned immediately.
   652 
   654 
   653      Redefined, to wait on pipes and sockets"
   655      Redefined, to wait on pipes and sockets"
   654 
   656 
   655     self atEnd ifTrue:[^ nil].
   657     self readWaitWithTimeoutMs:nil.
       
   658     handle isNil ifTrue:[
       
   659         "we were closed while waiting - so we are at the end"
       
   660         ^ nil.
       
   661     ].
   656     ^ super nextOrNil
   662     ^ super nextOrNil
   657 !
   663 !
   658 
   664 
   659 peek
   665 peek
   660     "Redefined, to wait on pipes and sockets"
   666     "Redefined, to wait on pipes and sockets"
   668      If nothing is available, this does never raise a read-beyond end signal.
   674      If nothing is available, this does never raise a read-beyond end signal.
   669      Instead, nil is returned immediately.
   675      Instead, nil is returned immediately.
   670 
   676 
   671      Redefined, to wait on pipes and sockets"
   677      Redefined, to wait on pipes and sockets"
   672 
   678 
   673     self atEnd ifTrue:[^ nil].
   679     self readWaitWithTimeoutMs:nil.
       
   680     handle isNil ifTrue:[
       
   681         "we were closed while waiting - so we are at the end"
       
   682         ^ nil.
       
   683     ].
   674     ^ self peek
   684     ^ self peek
   675 !
   685 !
   676 
   686 
   677 upTo:anObject into:aStream
   687 upTo:anObject into:aStream
   678     "read a collection of all objects up-to anObject and append these
   688     "read a collection of all objects up-to anObject and append these