class: NonPositionableExternalStream
added:
#collectionSize
#nextPutAll:from:startingAt:
#nextPutAll:startingAt:to:
#remainingSize
changed: #nextPutBytes:from:startingAt:
--- a/NonPositionableExternalStream.st Thu Mar 12 18:14:00 2015 +0100
+++ b/NonPositionableExternalStream.st Thu Mar 12 18:15:21 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -11,6 +13,8 @@
"
"{ Package: 'stx:libbasic' }"
+"{ NameSpace: Smalltalk }"
+
ExternalStream subclass:#NonPositionableExternalStream
instanceVariableNames:''
classVariableNames:'StdInStream StdOutStream StdErrorStream'
@@ -456,12 +460,24 @@
^ super atEnd.
!
+collectionSize
+ "we do not know our size"
+
+ ^ self positionError
+!
+
isPositionable
"return true, if the stream supports positioning (this one is not)"
^ false
!
+remainingSize
+ "we do not know our size"
+
+ ^ self positionError
+!
+
size
"we do not know our size"
@@ -519,21 +535,38 @@
!NonPositionableExternalStream methodsFor:'writing'!
+nextPutAll:aCollection startingAt:start to:stop
+ "redefined, to wait until stream is writable, to avoid blocking in a write"
+
+ |count|
+
+ count := stop-start+1.
+ count ~= (self nextPutBytes:count from:aCollection startingAt:start) ifTrue:[
+ "incomplete write"
+ self writeError.
+ ].
+!
+
nextPutBytes:initialWriteCount from:buffer startingAt:initialOffset
"redefined, to wait until stream is writable, to avoid blocking in a write"
- |count offset remaining wasBlocking|
+ |offset remaining wasBlocking|
offset := initialOffset.
remaining := initialWriteCount.
wasBlocking := self blocking:false.
[remaining ~~ 0] whileTrue:[
- count := super nextPutBytes:remaining from:buffer startingAt:offset.
- count ~~ remaining ifTrue:[ "Transcript showCR:'writeWait'. "self writeWait. ].
+ |count|
+
+ count := super nextPutBytes:remaining from:buffer startingAt:offset.
- remaining := remaining - count.
- offset := offset + count.
+ remaining := remaining - count.
+ offset := offset + count.
+ remaining ~~ 0 ifTrue:[
+ "Transcript showCR:'writeWait'."
+ self writeWait.
+ ].
].
wasBlocking ifTrue:[self blocking:true].
@@ -543,9 +576,10 @@
!NonPositionableExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.71 2014-04-16 14:33:08 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.72 2015-03-12 17:15:21 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.71 2014-04-16 14:33:08 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.72 2015-03-12 17:15:21 stefan Exp $'
! !
+