NonPositionableExternalStream.st
changeset 20680 bf04d4121195
parent 20644 c2b4ab689f0d
child 20685 4cf48622d541
equal deleted inserted replaced
20679:8c5a5321d13f 20680:bf04d4121195
       
     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 
   417     or:[self == Stdout
   400     or:[self == Stdout
   418     or:[self == Stderr]]) ifTrue:[
   401     or:[self == Stderr]]) ifTrue:[
   419 	^ self printOn:aStream
   402 	^ self printOn:aStream
   420     ].
   403     ].
   421     super storeOn:aStream
   404     super storeOn:aStream
       
   405 ! !
       
   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 ! !
   422 ! !
   423 
   423 
   424 !NonPositionableExternalStream methodsFor:'private'!
   424 !NonPositionableExternalStream methodsFor:'private'!
   425 
   425 
   426 handleForStderr
   426 handleForStderr
   650      If nothing is available, this does never raise a read-beyond end signal.
   650      If nothing is available, this does never raise a read-beyond end signal.
   651      Instead, nil is returned immediately.
   651      Instead, nil is returned immediately.
   652 
   652 
   653      Redefined, to wait on pipes and sockets"
   653      Redefined, to wait on pipes and sockets"
   654 
   654 
   655     self atEnd ifTrue:[^ nil].
   655     self readWaitWithTimeoutMs:nil.
       
   656     handle isNil ifTrue:[
       
   657         "we were closed while waiting - so we are at the end"
       
   658         ^ nil.
       
   659     ].
   656     ^ super nextOrNil
   660     ^ super nextOrNil
   657 !
   661 !
   658 
   662 
   659 peek
   663 peek
   660     "Redefined, to wait on pipes and sockets"
   664     "Redefined, to wait on pipes and sockets"
   668      If nothing is available, this does never raise a read-beyond end signal.
   672      If nothing is available, this does never raise a read-beyond end signal.
   669      Instead, nil is returned immediately.
   673      Instead, nil is returned immediately.
   670 
   674 
   671      Redefined, to wait on pipes and sockets"
   675      Redefined, to wait on pipes and sockets"
   672 
   676 
   673     self atEnd ifTrue:[^ nil].
   677     self readWaitWithTimeoutMs:nil.
       
   678     handle isNil ifTrue:[
       
   679         "we were closed while waiting - so we are at the end"
       
   680         ^ nil.
       
   681     ].
   674     ^ self peek
   682     ^ self peek
   675 !
   683 !
   676 
   684 
   677 upTo:anObject into:aStream
   685 upTo:anObject into:aStream
   678     "read a collection of all objects up-to anObject and append these
   686     "read a collection of all objects up-to anObject and append these