author | Stefan Vogel <sv@exept.de> |
Wed, 14 Jan 2009 21:02:09 +0100 | |
changeset 11455 | c78421a80b7c |
parent 10410 | 822f8baf6eaa |
child 11907 | 98248eb75a8d |
child 17711 | 39faaaf888b4 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
177 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
5407 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
1344
32a51164b237
No longer a subclass of UnboundedExternalStream, now subclass of ExternalStream.
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
14 |
ExternalStream subclass:#NonPositionableExternalStream |
1295 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'StdInStream StdOutStream StdErrorStream' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Streams-External' |
|
1 | 19 |
! |
20 |
||
613 | 21 |
!NonPositionableExternalStream primitiveDefinitions! |
22 |
%{ |
|
2896 | 23 |
|
5918 | 24 |
#ifndef _STDIO_H_INCLUDED_ |
25 |
# include <stdio.h> |
|
26 |
# define _STDIO_H_INCLUDED_ |
|
27 |
#endif |
|
3956
51f1a9a4d63f
changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents:
3808
diff
changeset
|
28 |
|
10410 | 29 |
#ifndef REMOVE_LATER |
30 |
# define __win32_stdout() stdout |
|
31 |
# define __win32_stderr() stderr |
|
32 |
# define __win32_stdin() stdin |
|
33 |
#else |
|
34 |
extern FILE *__win32_stdin(); |
|
35 |
extern FILE *__win32_stderr(); |
|
36 |
extern FILE *__win32_stdout(); |
|
37 |
#endif |
|
38 |
||
613 | 39 |
%} |
40 |
||
41 |
! ! |
|
42 |
||
88 | 43 |
!NonPositionableExternalStream class methodsFor:'documentation'! |
44 |
||
45 |
copyright |
|
46 |
" |
|
47 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
177 | 48 |
All Rights Reserved |
88 | 49 |
|
50 |
This software is furnished under a license and may be used |
|
51 |
only in accordance with the terms of that license and with the |
|
52 |
inclusion of the above copyright notice. This software may not |
|
53 |
be provided or otherwise made available to, or used by, any |
|
54 |
other person. No title to or ownership of the software is |
|
55 |
hereby transferred. |
|
56 |
" |
|
57 |
! |
|
58 |
||
59 |
documentation |
|
60 |
" |
|
61 |
This class provides common protocol for all non-positionable, |
|
62 |
external streams. Concrete subclasses are terminal streams, pipe streams, |
|
63 |
PrinterStreams, Sockets etc. |
|
64 |
||
65 |
There are three special instances of this class, representing stdin, |
|
66 |
stdout and stderr of the smalltalk/X process (see Unix manuals, if you |
|
177 | 67 |
dont know what those are used for). These special streams are bound to |
68 |
to globals Stdin, Stdout and Stderr at early initialization time |
|
69 |
(see Smalltalk>>initializeStandardStreams). |
|
159 | 70 |
|
71 |
The name of this class is a historical leftover - it should be called |
|
72 |
'TTYStream' or similar. |
|
1295 | 73 |
|
74 |
[author:] |
|
3808
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
75 |
Claus Gittinger |
88 | 76 |
" |
216 | 77 |
! ! |
78 |
||
1 | 79 |
!NonPositionableExternalStream class methodsFor:'instance creation'! |
80 |
||
613 | 81 |
forStderr |
2965 | 82 |
"{ Pragma: +optSpace }" |
83 |
||
613 | 84 |
"return a NonPositionableExternalStream object for writing to |
85 |
Unixes standard error output file descriptor" |
|
86 |
||
87 |
StdErrorStream isNil ifTrue:[ |
|
88 |
StdErrorStream := self basicNew initializeForStderr |
|
89 |
]. |
|
90 |
^ StdErrorStream |
|
91 |
! |
|
92 |
||
1 | 93 |
forStdin |
2965 | 94 |
"{ Pragma: +optSpace }" |
95 |
||
44 | 96 |
"return a NonPositionableExternalStream object for reading from |
97 |
Unixes standard input file descriptor" |
|
98 |
||
88 | 99 |
StdInStream isNil ifTrue:[ |
177 | 100 |
StdInStream := self basicNew initializeForStdin |
88 | 101 |
]. |
102 |
^ StdInStream |
|
1 | 103 |
! |
104 |
||
105 |
forStdout |
|
2965 | 106 |
"{ Pragma: +optSpace }" |
107 |
||
44 | 108 |
"return a NonPositionableExternalStream object for writing to |
109 |
Unixes standard output file descriptor" |
|
110 |
||
88 | 111 |
StdOutStream isNil ifTrue:[ |
177 | 112 |
StdOutStream := self basicNew initializeForStdout |
88 | 113 |
]. |
114 |
^ StdOutStream |
|
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
115 |
! |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
116 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
117 |
makePTYPair |
10327 | 118 |
"return an array with two streams - the first one is the master, |
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
119 |
the second the slave of a ptym/ptys pair. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
120 |
This is much like a bidirectional pipe, but allows signals & |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
121 |
control chars to be passed through the connection. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
122 |
This is needed to execute a shell in a view. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
123 |
This is the higher level equivalent of OperatingSystem>>makePTYPair |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
124 |
(which returns an array of file-descriptors)." |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
125 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
126 |
|ptyPair master slave| |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
127 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
128 |
ptyPair := OperatingSystem makePTYPair. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
129 |
ptyPair notNil ifTrue:[ |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
130 |
master := self forReadWriteToFileDescriptor:(ptyPair at:1). |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
131 |
master buffered:false. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
132 |
slave := self forReadWriteToFileDescriptor:(ptyPair at:2). |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
133 |
slave buffered:false. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
134 |
ptyPair at:1 put:master. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
135 |
ptyPair at:2 put:slave. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
136 |
^ ptyPair |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
137 |
]. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
138 |
^ nil |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
139 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
140 |
" |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
141 |
ExternalStream makePTYPair. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
142 |
" |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
143 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
144 |
"Modified: 29.2.1996 / 18:28:36 / cg" |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
145 |
! |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
146 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
147 |
makePipe |
10327 | 148 |
"return an array with two streams - the first one for reading, |
149 |
the second for writing. |
|
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
150 |
This is the higher level equivalent of OperatingSystem>>makePipe |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
151 |
(which returns an array of file-descriptors)." |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
152 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
153 |
|pipe rs ws| |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
154 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
155 |
pipe := OperatingSystem makePipe. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
156 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
157 |
pipe notNil ifTrue:[ |
10327 | 158 |
rs := self forReadingFromFileDescriptor:(pipe at:1). |
159 |
rs buffered:false. |
|
160 |
ws := self forWritingToFileDescriptor:(pipe at:2). |
|
161 |
ws buffered:false. |
|
162 |
^ Array with:rs with:ws |
|
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
163 |
]. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
164 |
^ nil |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
165 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
166 |
" |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
167 |
|pipe rs ws| |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
168 |
|
7541 | 169 |
pipe := NonPositionableExternalStream makePipe. |
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
170 |
rs := pipe at:1. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
171 |
ws := pipe at:2. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
172 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
173 |
'read ...'. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
174 |
[ |
10327 | 175 |
1 to:10 do:[:i | |
176 |
Transcript showCR:rs nextLine |
|
177 |
]. |
|
178 |
rs close. |
|
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
179 |
] forkAt:7. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
180 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
181 |
'write ...'. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
182 |
[ |
10327 | 183 |
1 to:10 do:[:i | |
184 |
ws nextPutAll:'hello world '; nextPutAll:i printString; cr |
|
185 |
]. |
|
186 |
ws close. |
|
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
187 |
] fork. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
188 |
" |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
189 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
190 |
"Modified: 29.2.1996 / 18:28:36 / cg" |
613 | 191 |
! ! |
192 |
||
193 |
!NonPositionableExternalStream methodsFor:'error handling'! |
|
194 |
||
195 |
positionError |
|
2965 | 196 |
"{ Pragma: +optSpace }" |
197 |
||
613 | 198 |
"notify that this stream has no concept of a position" |
199 |
||
8320
229adaeaf183
Use exception classes instead of class vars
Stefan Vogel <sv@exept.de>
parents:
7861
diff
changeset
|
200 |
^ PositionError raiseRequestWith:self |
4559 | 201 |
|
202 |
" |
|
203 |
Stderr positionError |
|
204 |
" |
|
613 | 205 |
! ! |
206 |
||
7861
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
207 |
!NonPositionableExternalStream methodsFor:'non homogenous reading'! |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
208 |
|
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
209 |
nextBytes:count into:anObject startingAt:start |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
210 |
"read the next count bytes into an object and return the number of |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
211 |
bytes read or the number of bytes read, if EOF is encountered before. |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
212 |
An exception is raised if the connection is broken. |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
213 |
|
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
214 |
Redefined here to avoid blocking of ST/X when waiting for io. |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
215 |
Instead only the calling thread will block" |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
216 |
|
8815 | 217 |
|remaining offset nRead| |
7861
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
218 |
|
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
219 |
count == 0 ifTrue:[ |
10327 | 220 |
^ 0. |
7861
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
221 |
]. |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
222 |
|
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
223 |
remaining := count. |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
224 |
offset := start. |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
225 |
|
10327 | 226 |
[ |
227 |
nRead := self nextAvailableBytes:remaining into:anObject startingAt:offset. |
|
228 |
nRead == 0 ifTrue:[ |
|
229 |
"atEnd does a readWait" |
|
230 |
self atEnd not. |
|
231 |
] ifFalse:[ |
|
232 |
remaining := remaining - nRead. |
|
233 |
offset := offset + nRead. |
|
234 |
remaining ~~ 0. |
|
235 |
] |
|
7861
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
236 |
] whileTrue. |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
237 |
|
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
238 |
^ count - remaining |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
239 |
! ! |
9c2cd42e4667
Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents:
7682
diff
changeset
|
240 |
|
613 | 241 |
!NonPositionableExternalStream methodsFor:'positioning'! |
242 |
||
243 |
position |
|
2965 | 244 |
"{ Pragma: +optSpace }" |
245 |
||
613 | 246 |
"catch position - there is none here" |
247 |
||
248 |
^ self positionError |
|
1 | 249 |
! |
250 |
||
613 | 251 |
position:aPosition |
2965 | 252 |
"{ Pragma: +optSpace }" |
253 |
||
613 | 254 |
"catch position - there is none here" |
255 |
||
256 |
^ self positionError |
|
257 |
! |
|
44 | 258 |
|
613 | 259 |
skip:numberToSkip |
7241 | 260 |
"skip count bytes/characters, return the receiver. |
261 |
Re-redefined since PositionableStream redefined it." |
|
613 | 262 |
|
263 |
"dont know how to unread ..." |
|
264 |
numberToSkip < 0 ifTrue:[ |
|
10327 | 265 |
PositionError raiseRequest. |
266 |
^ self |
|
88 | 267 |
]. |
613 | 268 |
numberToSkip timesRepeat:self next |
4467 | 269 |
|
270 |
"Modified: / 30.7.1999 / 12:42:12 / cg" |
|
3173
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
271 |
! |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
272 |
|
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
273 |
skipThroughAll:aCollection |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
274 |
"skip for and through the sequence given by the argument, aCollection; |
10327 | 275 |
return nil if not found, the receiver otherwise. |
3173
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
276 |
On a successful match, the next read will return elements after aCollection; |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
277 |
if no match was found, the receiver will be positioned at the end. |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
278 |
Redefined to be the same as Stream>>#skipThroughAll, to undo |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
279 |
the redefinition from PositionableStream" |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
280 |
|
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
281 |
|buffer l first idx| |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
282 |
|
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
283 |
l := aCollection size. |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
284 |
first := aCollection at:1. |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
285 |
[self atEnd] whileFalse:[ |
3808
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
286 |
buffer isNil ifTrue:[ |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
287 |
buffer := self nextAvailable:l. |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
288 |
]. |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
289 |
buffer = aCollection ifTrue:[ |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
290 |
^ self |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
291 |
]. |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
292 |
idx := buffer indexOf:first startingAt:2. |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
293 |
idx == 0 ifTrue:[ |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
294 |
buffer := nil |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
295 |
] ifFalse:[ |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
296 |
buffer := (buffer copyFrom:idx) , (self nextAvailable:(idx - 1)) |
5a7866138026
set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents:
3173
diff
changeset
|
297 |
] |
3173
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
298 |
]. |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
299 |
^ nil |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
300 |
|
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
301 |
" |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
302 |
|s| |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
303 |
s := ReadStream on:'12345678901234567890'. |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
304 |
s skipThroughAll:'901'. |
10327 | 305 |
s upToEnd |
3173
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
306 |
" |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
307 |
" |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
308 |
|s| |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
309 |
s := ReadStream on:'12345678901234567890'. |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
310 |
s skipThroughAll:'1234'. |
10327 | 311 |
s upToEnd |
3173
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
312 |
" |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
313 |
" |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
314 |
|s| |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
315 |
s := ReadStream on:'12345678901234567890'. |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
316 |
s skipThroughAll:'999'. |
10327 | 317 |
s atEnd |
3173
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
318 |
" |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
319 |
|
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
320 |
"Modified: / 11.1.1997 / 19:09:06 / cg" |
664f2ffa7493
Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents:
2965
diff
changeset
|
321 |
"Created: / 15.1.1998 / 23:33:37 / stefan" |
1 | 322 |
! ! |
323 |
||
177 | 324 |
!NonPositionableExternalStream methodsFor:'printing & storing'! |
325 |
||
326 |
printOn:aStream |
|
2965 | 327 |
"{ Pragma: +optSpace }" |
328 |
||
4392 | 329 |
"append a user printed representation of the receiver to aStream. |
330 |
The format is suitable for a human - not meant to be read back." |
|
177 | 331 |
|
2965 | 332 |
|myName| |
333 |
||
177 | 334 |
self == Stdin ifTrue:[ |
10327 | 335 |
myName := 'Stdin'. |
2965 | 336 |
] ifFalse:[ |
10327 | 337 |
self == Stdout ifTrue:[ |
338 |
myName := 'Stdout'. |
|
339 |
] ifFalse:[ |
|
340 |
self == Stderr ifTrue:[ |
|
341 |
myName := 'Stderr'. |
|
342 |
] |
|
343 |
] |
|
177 | 344 |
]. |
2965 | 345 |
|
346 |
myName notNil ifTrue:[ |
|
10327 | 347 |
aStream nextPutAll:myName. |
348 |
^ self |
|
177 | 349 |
]. |
350 |
super printOn:aStream |
|
351 |
! |
|
352 |
||
353 |
storeOn:aStream |
|
2965 | 354 |
"{ Pragma: +optSpace }" |
355 |
||
213 | 356 |
"append a printed representation of the receiver on aStream, from |
357 |
which the receiver can be reconstructed." |
|
177 | 358 |
|
359 |
((self == Stdin) |
|
360 |
or:[self == Stdout |
|
361 |
or:[self == Stderr]]) ifTrue:[ |
|
362 |
^ self printOn:aStream |
|
363 |
]. |
|
364 |
super storeOn:aStream |
|
365 |
! ! |
|
366 |
||
613 | 367 |
!NonPositionableExternalStream methodsFor:'private'! |
360 | 368 |
|
5407 | 369 |
handleForStderr |
370 |
"{ Pragma: +optSpace }" |
|
371 |
||
372 |
"return a stderr handle" |
|
373 |
||
374 |
%{ |
|
10327 | 375 |
#ifdef WIN32 |
376 |
RETURN ( __MKOBJ( __win32_stderr() )); |
|
377 |
#else |
|
5407 | 378 |
RETURN ( __MKOBJ(stderr) ); |
10327 | 379 |
#endif |
5407 | 380 |
%} |
381 |
! |
|
382 |
||
383 |
handleForStdin |
|
384 |
"{ Pragma: +optSpace }" |
|
385 |
||
386 |
"return a stdin handle" |
|
387 |
||
388 |
%{ |
|
10327 | 389 |
#ifdef WIN32 |
390 |
RETURN ( __MKOBJ( __win32_stdin() )); |
|
391 |
#else |
|
5407 | 392 |
RETURN ( __MKOBJ(stdin) ); |
10327 | 393 |
#endif |
5407 | 394 |
%} |
395 |
! |
|
396 |
||
397 |
handleForStdout |
|
398 |
"{ Pragma: +optSpace }" |
|
399 |
||
400 |
"return a stdout handle" |
|
401 |
||
402 |
%{ |
|
10327 | 403 |
#ifdef WIN32 |
404 |
RETURN ( __MKOBJ( __win32_stdout() )); |
|
405 |
#else |
|
5407 | 406 |
RETURN ( __MKOBJ(stdout) ); |
10327 | 407 |
#endif |
5407 | 408 |
%} |
409 |
! |
|
410 |
||
613 | 411 |
initializeForStderr |
2965 | 412 |
"{ Pragma: +optSpace }" |
413 |
||
613 | 414 |
"setup for writing to stderr" |
269 | 415 |
|
613 | 416 |
mode := #readwrite. |
417 |
buffered := false. |
|
5407 | 418 |
filePointer := self handleForStderr. |
419 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
10327 | 420 |
eolMode := #crlf |
5407 | 421 |
] |
613 | 422 |
! |
1 | 423 |
|
424 |
initializeForStdin |
|
2965 | 425 |
"{ Pragma: +optSpace }" |
426 |
||
44 | 427 |
"setup for reading stdin" |
428 |
||
1 | 429 |
mode := #readonly. |
6843
ef53f65b7364
stdout/err must not be buffered (sending prompts without NL)
Claus Gittinger <cg@exept.de>
parents:
5918
diff
changeset
|
430 |
"/ buffered := true. |
ef53f65b7364
stdout/err must not be buffered (sending prompts without NL)
Claus Gittinger <cg@exept.de>
parents:
5918
diff
changeset
|
431 |
buffered := false. |
5407 | 432 |
filePointer := self handleForStdin. |
1 | 433 |
! |
434 |
||
435 |
initializeForStdout |
|
2965 | 436 |
"{ Pragma: +optSpace }" |
437 |
||
44 | 438 |
"setup for writing to stdout" |
439 |
||
1 | 440 |
mode := #readwrite. |
10 | 441 |
buffered := false. |
5407 | 442 |
filePointer := self handleForStdout. |
443 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
10327 | 444 |
eolMode := #crlf |
5407 | 445 |
] |
1 | 446 |
! |
447 |
||
448 |
reOpen |
|
2965 | 449 |
"{ Pragma: +optSpace }" |
450 |
||
44 | 451 |
"reopen the stream after an image restart. |
452 |
If I am one of the standard streams, reopen is easy" |
|
1 | 453 |
|
477
8710aba7876b
oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents:
475
diff
changeset
|
454 |
(self == StdInStream) ifTrue:[ |
177 | 455 |
^ self initializeForStdin |
1 | 456 |
]. |
477
8710aba7876b
oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents:
475
diff
changeset
|
457 |
(self == StdOutStream) ifTrue:[ |
177 | 458 |
^ self initializeForStdout |
1 | 459 |
]. |
477
8710aba7876b
oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents:
475
diff
changeset
|
460 |
(self == StdErrorStream) ifTrue:[ |
177 | 461 |
^ self initializeForStderr |
1 | 462 |
]. |
463 |
^ super reOpen |
|
464 |
! ! |
|
613 | 465 |
|
466 |
!NonPositionableExternalStream methodsFor:'queries'! |
|
467 |
||
5851
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
468 |
atEnd |
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
469 |
"return true, if position is at end" |
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
470 |
|
5918 | 471 |
(self == StdInStream) ifTrue:[ |
472 |
OperatingSystem hasConsole ifFalse:[ |
|
473 |
^ true |
|
474 |
] |
|
475 |
]. |
|
476 |
||
5851
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
477 |
"first, wait to avoid blocking on the read. |
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
478 |
On end of stream or error, readWait will return" |
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
479 |
|
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
480 |
self readWait. |
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
481 |
^ super atEnd. |
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
482 |
! |
6823cc642d60
only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
483 |
|
4962
0023029d2522
allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents:
4559
diff
changeset
|
484 |
current |
0023029d2522
allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents:
4559
diff
changeset
|
485 |
"for compatibility with Transcript - allow Transcript current, |
0023029d2522
allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents:
4559
diff
changeset
|
486 |
even if redirected to the standardError" |
0023029d2522
allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents:
4559
diff
changeset
|
487 |
|
0023029d2522
allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents:
4559
diff
changeset
|
488 |
self == Transcript ifTrue:[ |
0023029d2522
allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents:
4559
diff
changeset
|
489 |
^ self |
0023029d2522
allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents:
4559
diff
changeset
|
490 |
]. |
0023029d2522
allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents:
4559
diff
changeset
|
491 |
^ super current |
5407 | 492 |
! |
493 |
||
494 |
isPositionable |
|
495 |
"return true, if the stream supports positioning (this one is not)" |
|
496 |
||
497 |
^ false |
|
11455 | 498 |
! |
499 |
||
500 |
size |
|
501 |
"we do not know our size" |
|
502 |
||
503 |
^ self positionError |
|
613 | 504 |
! ! |
505 |
||
10349
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
506 |
!NonPositionableExternalStream methodsFor:'reading'! |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
507 |
|
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
508 |
nextOrNil |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
509 |
"like #next, this returns the next element, if available. |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
510 |
If nothing is available, this does never raise a read-beyond end signal. |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
511 |
Instead, nil is returned immediately. |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
512 |
|
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
513 |
Redefined, to wait on pipes and sockets" |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
514 |
|
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
515 |
self atEnd ifTrue:[^ nil]. |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
516 |
^ self next |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
517 |
! |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
518 |
|
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
519 |
peekOrNil |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
520 |
"like #peek, this returns the next element, if available. |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
521 |
If nothing is available, this does never raise a read-beyond end signal. |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
522 |
Instead, nil is returned immediately. |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
523 |
|
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
524 |
Redefined, to wait on pipes and sockets" |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
525 |
|
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
526 |
self atEnd ifTrue:[^ nil]. |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
527 |
^ self peek |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
528 |
! ! |
cbfa00bba11d
Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents:
10327
diff
changeset
|
529 |
|
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
530 |
!NonPositionableExternalStream methodsFor:'writing'! |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
531 |
|
7679 | 532 |
nextPutBytes:initialWriteCount from:buffer startingAt:initialOffset |
533 |
"redefined, to wait until stream is writable, to avoid blocking in a write" |
|
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
534 |
|
7682
5d43745f59ac
only do a writeWait if previous non-blocking write failed to
Claus Gittinger <cg@exept.de>
parents:
7679
diff
changeset
|
535 |
|count offset remaining wasBlocking| |
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
536 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
537 |
offset := initialOffset. |
7679 | 538 |
remaining := initialWriteCount. |
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
539 |
|
7679 | 540 |
wasBlocking := self blocking:false. |
10327 | 541 |
[remaining ~~ 0] whileTrue:[ |
542 |
count := super nextPutBytes:remaining from:buffer startingAt:offset. |
|
543 |
count ~~ remaining ifTrue:[ self writeWait. ]. |
|
7682
5d43745f59ac
only do a writeWait if previous non-blocking write failed to
Claus Gittinger <cg@exept.de>
parents:
7679
diff
changeset
|
544 |
|
10327 | 545 |
remaining := remaining - count. |
546 |
offset := offset + count. |
|
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
547 |
]. |
7679 | 548 |
wasBlocking ifTrue:[self blocking:true]. |
549 |
||
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
550 |
^ offset - initialOffset. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
551 |
! ! |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7241
diff
changeset
|
552 |
|
1295 | 553 |
!NonPositionableExternalStream class methodsFor:'documentation'! |
554 |
||
555 |
version |
|
11455 | 556 |
^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.55 2009-01-14 20:02:09 stefan Exp $' |
1295 | 557 |
! ! |