912
|
1 |
"{ Package: 'stx:libbasic2' }"
|
|
2 |
|
833
|
3 |
Stream subclass:#SplittingWriteStream
|
|
4 |
instanceVariableNames:'outStream1 outStream2'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Streams-Misc'
|
|
8 |
!
|
|
9 |
|
|
10 |
!SplittingWriteStream class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
documentation
|
|
13 |
"
|
|
14 |
A stream duplicator - everything written onto a splittingWriteStream
|
|
15 |
is written to two real streams.
|
|
16 |
Useful, if you have to send something to two files/destinations
|
|
17 |
simultaneously, and do not want to (or cannot) buffer it.
|
|
18 |
Especially useful, to generate a checksum,
|
|
19 |
while sending something to a file
|
|
20 |
(if one of the output streams is a checksummer).
|
|
21 |
|
|
22 |
[author:]
|
|
23 |
Claus Gittinger (cg@exept)
|
|
24 |
|
|
25 |
[see also:]
|
|
26 |
WriteStream
|
|
27 |
|
|
28 |
[instance variables:]
|
|
29 |
outStream1 <Stream> actual output streams
|
|
30 |
outStream2 <Stream>
|
|
31 |
|
|
32 |
[class variables:]
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
examples
|
|
37 |
"
|
|
38 |
examples to be added.
|
|
39 |
[exBegin]
|
|
40 |
|s1 s2 splitter|
|
|
41 |
|
|
42 |
s1 := '/tmp/foo1' asFilename writeStream.
|
|
43 |
s2 := '/tmp/foo2' asFilename writeStream.
|
|
44 |
splitter := SplittingWriteStream on:s1 and:s2.
|
|
45 |
splitter nextPutAll:'hello world'.
|
|
46 |
splitter close.
|
|
47 |
[exEnd]
|
|
48 |
"
|
|
49 |
! !
|
|
50 |
|
|
51 |
!SplittingWriteStream class methodsFor:'instance creation'!
|
|
52 |
|
|
53 |
on:stream1 and:stream2
|
|
54 |
^ self basicNew setOutStream1:stream1 outStream2:stream2
|
|
55 |
! !
|
|
56 |
|
912
|
57 |
!SplittingWriteStream methodsFor:'accessing'!
|
|
58 |
|
|
59 |
outStream1
|
|
60 |
"return the value of the instance variable 'outStream1' (automatically generated)"
|
|
61 |
|
|
62 |
^ outStream1!
|
|
63 |
|
|
64 |
outStream1:something
|
|
65 |
"set the value of the instance variable 'outStream1' (automatically generated)"
|
|
66 |
|
|
67 |
outStream1 := something.!
|
|
68 |
|
|
69 |
outStream2
|
|
70 |
"return the value of the instance variable 'outStream2' (automatically generated)"
|
|
71 |
|
|
72 |
^ outStream2!
|
|
73 |
|
|
74 |
outStream2:something
|
|
75 |
"set the value of the instance variable 'outStream2' (automatically generated)"
|
|
76 |
|
|
77 |
outStream2 := something.! !
|
|
78 |
|
833
|
79 |
!SplittingWriteStream methodsFor:'private access'!
|
|
80 |
|
|
81 |
setOutStream1:stream1 outStream2:stream2
|
|
82 |
outStream1 := stream1.
|
|
83 |
outStream2 := stream2.
|
|
84 |
|
|
85 |
! !
|
|
86 |
|
|
87 |
!SplittingWriteStream methodsFor:'writing'!
|
|
88 |
|
|
89 |
close
|
|
90 |
outStream1 close.
|
|
91 |
outStream2 close.
|
|
92 |
|
|
93 |
!
|
|
94 |
|
|
95 |
endEntry
|
|
96 |
outStream1 endEntry.
|
|
97 |
outStream2 endEntry.
|
|
98 |
|
|
99 |
!
|
|
100 |
|
|
101 |
flush
|
|
102 |
outStream1 flush.
|
|
103 |
outStream2 flush.
|
|
104 |
|
|
105 |
!
|
|
106 |
|
|
107 |
nextPut:something
|
|
108 |
outStream1 nextPut:something.
|
|
109 |
outStream2 nextPut:something.
|
|
110 |
|
|
111 |
!
|
|
112 |
|
|
113 |
nextPutAll:something
|
|
114 |
outStream1 nextPutAll:something.
|
|
115 |
outStream2 nextPutAll:something.
|
|
116 |
|
|
117 |
! !
|
|
118 |
|
|
119 |
!SplittingWriteStream class methodsFor:'documentation'!
|
|
120 |
|
|
121 |
version
|
912
|
122 |
^ '$Header: /cvs/stx/stx/libbasic2/SplittingWriteStream.st,v 1.2 2000-09-11 18:09:01 cg Exp $'
|
833
|
123 |
! !
|