"{ Package: 'stx:goodies/xtreams/terminals' }"
"{ NameSpace: Xtreams }"
WriteStream subclass:#ExternalWriteStream
instanceVariableNames:'contentsSpecies'
classVariableNames:''
poolDictionaries:''
category:'Xtreams-Terminals'
!
ExternalWriteStream comment:'Used to write to BlockableIOAccessors (e.g sockets or pipes). This is a binary stream (consumes bytes/ByteArrays).
{{{
[ :in :out |
[ out writing write: ''Hello''; close.
in reading read: 5
] ensure: [ in close. out close ]
] valueWithArguments: SocketAccessor openPair
}}}
{{{
[ :in :out |
[ out writing write: ''Hello''; close.
in reading read: 5
] ensure: [ in close. out close ]
] valueWithArguments: OSSystemSupport concreteClass pipeAccessorClass openPair
}}}
Instance Variables
contentsSpecies <Class> species for collections of elements of this stream
'
!
!ExternalWriteStream methodsFor:'accessing'!
write: anInteger from: aSequenceableCollection at: startIndex
| count wrote |
anInteger isZero ifTrue: [^0].
count := 0.
[count < anInteger] whileTrue:
[wrote := destination nextPutBytes: anInteger - count from: aSequenceableCollection startingAt: startIndex + count.
wrote isZero ifTrue: [(Incomplete on: aSequenceableCollection count: count at: startIndex) raise].
count := count + wrote].
^anInteger
! !
!ExternalWriteStream methodsFor:'initialize-release'!
close
destination isActive ifFalse: [^self].
destination close
!
contentsSpecies
^contentsSpecies
!
contentsSpecies: aClass
contentsSpecies := aClass
!
on: anAccessor
super on: anAccessor.
contentsSpecies := ByteArray
! !
!ExternalWriteStream class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !