NonPositionableExternalStream.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 09 Apr 2011 18:19:04 +0100
branchjv
changeset 17834 04ff72c5039a
parent 17814 b75a7f0c346b
child 17841 7abcc4aef871
permissions -rw-r--r--
Merged with /trunk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
    12
"{ Package: 'stx:libbasic' }"
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
    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
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    15
	instanceVariableNames:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    16
	classVariableNames:'StdInStream StdOutStream StdErrorStream'
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    17
	poolDictionaries:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    18
	category:'Streams-External'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    21
!NonPositionableExternalStream primitiveDefinitions!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    22
%{
2896
be30640b9012 VMS stuff
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
    23
5918
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
    24
#ifndef _STDIO_H_INCLUDED_
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
    25
# include <stdio.h>
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
    26
# define _STDIO_H_INCLUDED_
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
    27
#endif
3956
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3808
diff changeset
    28
10410
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    29
#ifndef REMOVE_LATER
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    30
# define __win32_stdout()        stdout
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    31
# define __win32_stderr()        stderr
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    32
# define __win32_stdin()         stdin
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    33
#else
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    34
    extern FILE *__win32_stdin();
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    35
    extern FILE *__win32_stderr();
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    36
    extern FILE *__win32_stdout();
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    37
#endif
822f8baf6eaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10349
diff changeset
    38
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    39
%}
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    40
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    41
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    42
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    43
!NonPositionableExternalStream class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    44
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    45
copyright
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    46
"
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    47
 COPYRIGHT (c) 1989 by Claus Gittinger
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    48
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    49
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    50
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    51
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    52
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    53
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    54
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    55
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    56
"
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    57
!
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    58
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    59
documentation
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    60
"
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    61
    This class provides common protocol for all non-positionable,
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    62
    external streams. Concrete subclasses are terminal streams, pipe streams,
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    63
    PrinterStreams, Sockets etc.
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    64
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    65
    There are three special instances of this class, representing stdin,
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    66
    stdout and stderr of the smalltalk/X process (see Unix manuals, if you
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    67
    dont know what those are used for). These special streams are bound to
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    68
    to globals Stdin, Stdout and Stderr at early initialization time
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    69
    (see Smalltalk>>initializeStandardStreams).
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    70
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    71
    The name of this class is a historical leftover - it should be called
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    72
    'TTYStream' or similar.
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    73
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    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
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    76
"
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
    77
! !
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
    78
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    79
!NonPositionableExternalStream class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    80
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    81
forStderr
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    82
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    83
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    84
    "return a NonPositionableExternalStream object for writing to
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    85
     Unixes standard error output file descriptor"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    86
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    87
    StdErrorStream isNil ifTrue:[
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    88
	StdErrorStream := self basicNew initializeForStderr
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    89
    ].
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    90
    ^ StdErrorStream
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    91
!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    92
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    93
forStdin
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    94
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    95
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    96
    "return a NonPositionableExternalStream object for reading from
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    97
     Unixes standard input file descriptor"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    98
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    99
    StdInStream isNil ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   100
	StdInStream := self basicNew initializeForStdin
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   101
    ].
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   102
    ^ StdInStream
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   103
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   104
a27a279701f8 Initial revision
claus
parents:
diff changeset
   105
forStdout
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   106
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   107
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   108
    "return a NonPositionableExternalStream object for writing to
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   109
     Unixes standard output file descriptor"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   110
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   111
    StdOutStream isNil ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   112
	StdOutStream := self basicNew initializeForStdout
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   113
    ].
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   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
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   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
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   148
    "return an array with two streams - the first one for reading,
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   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
17732
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   153
    |pipe rs ws|
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   154
17732
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   155
    pipe := OperatingSystem makePipe.
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   156
    pipe isNil ifTrue:[
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   157
        "/ ok, maybe someone has forgotten to close a stream; enforce finalization and try again
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   158
        'makePipe: enforcing finalization to close any open streams' infoPrintCR.
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   159
        ObjectMemory garbageCollect; finalize.
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   160
        pipe := OperatingSystem makePipe.
17732
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   161
    ].
17734
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17732
diff changeset
   162
17732
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   163
    pipe notNil ifTrue:[
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   164
        rs := self forFileDescriptor:(pipe at:1) mode:#readonly buffered:false handleType:#pipeFilePointer.
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   165
        ws := self forFileDescriptor:(pipe at:2) mode:#writeonly buffered:false handleType:#pipeFilePointer.
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   166
        ^ Array with:rs with:ws
17732
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   167
    ].
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   168
    ^ nil
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   169
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   170
    "
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   171
     |pipe rs ws|
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   172
7541
e980e3695dee Fix comments
Stefan Vogel <sv@exept.de>
parents: 7501
diff changeset
   173
     pipe := NonPositionableExternalStream makePipe.
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   174
     rs := pipe at:1.
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   175
     ws := pipe at:2.
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   176
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   177
     'read ...'.
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   178
     [
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   179
         1 to:10 do:[:i |
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   180
             Transcript showCR:rs nextLine
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   181
         ].
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   182
         rs close.
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   183
     ] forkAt:7.
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   184
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   185
     'write ...'.
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   186
     [
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   187
         1 to:10 do:[:i |
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   188
             ws nextPutAll:'hello world '; nextPutAll:i printString; cr
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   189
         ].
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   190
         ws close.
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   191
     ] fork.
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   192
    "
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   193
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   194
    "Modified: 29.2.1996 / 18:28:36 / cg"
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   195
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   196
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   197
!NonPositionableExternalStream methodsFor:'error handling'!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   198
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   199
positionError
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   200
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   201
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   202
    "notify that this stream has no concept of a position"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   203
8320
229adaeaf183 Use exception classes instead of class vars
Stefan Vogel <sv@exept.de>
parents: 7861
diff changeset
   204
    ^ PositionError raiseRequestWith:self
4559
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4467
diff changeset
   205
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4467
diff changeset
   206
    "
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4467
diff changeset
   207
     Stderr positionError
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4467
diff changeset
   208
    "
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   209
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   210
7861
9c2cd42e4667 Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents: 7682
diff changeset
   211
!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
   212
9c2cd42e4667 Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents: 7682
diff changeset
   213
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
   214
    "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
   215
     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
   216
     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
   217
9c2cd42e4667 Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents: 7682
diff changeset
   218
     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
   219
     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
   220
8815
88c21d3f2c9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8320
diff changeset
   221
    |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
   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
    count == 0 ifTrue:[
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   224
	^ 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
   225
    ].
9c2cd42e4667 Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents: 7682
diff changeset
   226
9c2cd42e4667 Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents: 7682
diff changeset
   227
    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
   228
    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
   229
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   230
    [
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   231
	nRead := self nextAvailableBytes:remaining into:anObject startingAt:offset.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   232
	nRead == 0 ifTrue:[
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   233
	    "atEnd does a readWait"
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   234
	    self atEnd not.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   235
	] ifFalse:[
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   236
	    remaining := remaining - nRead.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   237
	    offset := offset + nRead.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   238
	    remaining ~~ 0.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   239
	]
7861
9c2cd42e4667 Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents: 7682
diff changeset
   240
    ] whileTrue.
9c2cd42e4667 Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents: 7682
diff changeset
   241
9c2cd42e4667 Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents: 7682
diff changeset
   242
    ^ 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
   243
! !
9c2cd42e4667 Provide a #nextBytes:into:startingAt: that does not block the whole ST/X
Stefan Vogel <sv@exept.de>
parents: 7682
diff changeset
   244
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   245
!NonPositionableExternalStream methodsFor:'positioning'!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   246
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   247
position
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   248
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   249
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   250
    "catch position - there is none here"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   251
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   252
    ^ self positionError
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   253
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   254
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   255
position:aPosition
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   256
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   257
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   258
    "catch position - there is none here"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   259
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   260
    ^ self positionError
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   261
!
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   262
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   263
skip:numberToSkip
7241
06359d192b65 comment
Claus Gittinger <cg@exept.de>
parents: 6843
diff changeset
   264
    "skip count bytes/characters, return the receiver.
06359d192b65 comment
Claus Gittinger <cg@exept.de>
parents: 6843
diff changeset
   265
     Re-redefined since PositionableStream redefined it."
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   266
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   267
    "dont know how to unread ..."
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   268
    numberToSkip < 0 ifTrue:[
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   269
	PositionError raiseRequest.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   270
	^ self
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   271
    ].
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   272
    numberToSkip timesRepeat:self next
4467
8ddf534d7d81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4392
diff changeset
   273
8ddf534d7d81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4392
diff changeset
   274
    "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
   275
!
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   276
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   277
skipThroughAll:aCollection
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   278
    "skip for and through the sequence given by the argument, aCollection;
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   279
     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
   280
     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
   281
     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
   282
     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
   283
     the redefinition from PositionableStream"
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   284
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   285
    |buffer l first idx|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   286
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   287
    l := aCollection size.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   288
    first := aCollection at:1.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   289
    [self atEnd] whileFalse:[
3808
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   290
	buffer isNil ifTrue:[
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   291
	    buffer := self nextAvailable:l.
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   292
	].
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   293
	buffer = aCollection ifTrue:[
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   294
	    ^ self
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   295
	].
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   296
	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
   297
	idx == 0 ifTrue:[
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   298
	    buffer := nil
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   299
	] ifFalse:[
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   300
	    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
   301
	]
3173
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   302
    ].
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   303
    ^ nil
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   304
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   305
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   306
     |s|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   307
     s := ReadStream on:'12345678901234567890'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   308
     s skipThroughAll:'901'.
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   309
     s upToEnd
3173
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   310
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   311
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   312
     |s|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   313
     s := ReadStream on:'12345678901234567890'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   314
     s skipThroughAll:'1234'.
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   315
     s upToEnd
3173
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   316
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   317
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   318
     |s|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   319
     s := ReadStream on:'12345678901234567890'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   320
     s skipThroughAll:'999'.
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   321
     s atEnd
3173
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   322
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   323
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   324
    "Modified: / 11.1.1997 / 19:09:06 / cg"
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   325
    "Created: / 15.1.1998 / 23:33:37 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   326
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   327
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   328
!NonPositionableExternalStream methodsFor:'printing & storing'!
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   329
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   330
printOn:aStream
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   331
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   332
4392
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   333
    "append a user printed representation of the receiver to aStream.
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   334
     The format is suitable for a human - not meant to be read back."
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   335
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   336
    |myName|
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   337
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   338
    self == Stdin ifTrue:[
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   339
	myName := 'Stdin'.
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   340
    ] ifFalse:[
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   341
	self == Stdout ifTrue:[
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   342
	    myName := 'Stdout'.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   343
	] ifFalse:[
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   344
	    self == Stderr ifTrue:[
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   345
		myName := 'Stderr'.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   346
	    ]
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   347
	]
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   348
    ].
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   349
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   350
    myName notNil ifTrue:[
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   351
	aStream nextPutAll:myName.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   352
	^ self
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   353
    ].
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   354
    super printOn:aStream
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   355
!
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   356
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   357
storeOn:aStream
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   358
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   359
213
3b56a17534fd *** empty log message ***
claus
parents: 177
diff changeset
   360
    "append a printed representation of the receiver on aStream, from
3b56a17534fd *** empty log message ***
claus
parents: 177
diff changeset
   361
     which the receiver can be reconstructed."
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   362
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   363
    ((self == Stdin)
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   364
    or:[self == Stdout
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   365
    or:[self == Stderr]]) ifTrue:[
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   366
	^ self printOn:aStream
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   367
    ].
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   368
    super storeOn:aStream
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   369
! !
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   370
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   371
!NonPositionableExternalStream methodsFor:'private'!
360
claus
parents: 269
diff changeset
   372
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   373
handleForStderr
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   374
    "{ Pragma: +optSpace }"
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   375
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   376
    "return a stderr handle"
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   377
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   378
%{
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   379
#ifdef WIN32
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   380
    RETURN ( __MKEXTERNALADDRESS( __win32_stderr() ));
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   381
#else
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   382
    RETURN ( __MKEXTERNALADDRESS(stderr) );
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   383
#endif
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   384
%}
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   385
!
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   386
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   387
handleForStdin
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   388
    "{ Pragma: +optSpace }"
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   389
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   390
    "return a stdin handle"
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   391
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   392
%{
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   393
#ifdef WIN32
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   394
    RETURN ( __MKEXTERNALADDRESS( __win32_stdin() ));
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   395
#else
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   396
    RETURN ( __MKEXTERNALADDRESS(stdin) );
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   397
#endif
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   398
%}
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   399
!
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   400
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   401
handleForStdout
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   402
    "{ Pragma: +optSpace }"
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   403
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   404
    "return a stdout handle"
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   405
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   406
%{
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   407
#ifdef WIN32
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   408
    RETURN ( __MKEXTERNALADDRESS( __win32_stdout() ));
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   409
#else
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   410
    RETURN ( __MKEXTERNALADDRESS(stdout) );
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   411
#endif
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   412
%}
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   413
!
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   414
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   415
initializeForStderr
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   416
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   417
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   418
    "setup for writing to stderr"
269
93162487a94b *** empty log message ***
claus
parents: 216
diff changeset
   419
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   420
    mode := #readwrite.
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   421
    buffered := false.
17734
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17732
diff changeset
   422
    handle := self handleForStderr.
17754
5322906cdb6a Merged with trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17751
diff changeset
   423
    handleType := #filePointer.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   424
    OperatingSystem isMSWINDOWSlike ifTrue:[
17754
5322906cdb6a Merged with trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17751
diff changeset
   425
        eolMode := #crlf
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   426
    ]
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   427
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   428
a27a279701f8 Initial revision
claus
parents:
diff changeset
   429
initializeForStdin
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   430
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   431
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   432
    "setup for reading stdin"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   433
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   434
    mode := #readonly.
6843
ef53f65b7364 stdout/err must not be buffered (sending prompts without NL)
Claus Gittinger <cg@exept.de>
parents: 5918
diff changeset
   435
    "/ buffered := true.
ef53f65b7364 stdout/err must not be buffered (sending prompts without NL)
Claus Gittinger <cg@exept.de>
parents: 5918
diff changeset
   436
    buffered := false.
17754
5322906cdb6a Merged with trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17751
diff changeset
   437
    handleType := #filePointer.
17734
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17732
diff changeset
   438
    handle := self handleForStdin.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   439
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   440
a27a279701f8 Initial revision
claus
parents:
diff changeset
   441
initializeForStdout
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   442
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   443
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   444
    "setup for writing to stdout"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   445
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   446
    mode := #readwrite.
10
claus
parents: 5
diff changeset
   447
    buffered := false.
17734
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17732
diff changeset
   448
    handle := self handleForStdout.
17754
5322906cdb6a Merged with trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17751
diff changeset
   449
    handleType := #filePointer.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   450
    OperatingSystem isMSWINDOWSlike ifTrue:[
17754
5322906cdb6a Merged with trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17751
diff changeset
   451
        eolMode := #crlf
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   452
    ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   453
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   454
a27a279701f8 Initial revision
claus
parents:
diff changeset
   455
reOpen
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   456
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   457
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   458
    "reopen the stream after an image restart.
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   459
     If I am one of the standard streams, reopen is easy"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   460
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   461
    (self == StdInStream) ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   462
	^ self initializeForStdin
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   463
    ].
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   464
    (self == StdOutStream) ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   465
	^ self initializeForStdout
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   466
    ].
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   467
    (self == StdErrorStream) ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   468
	^ self initializeForStderr
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   469
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   470
    ^ super reOpen
a27a279701f8 Initial revision
claus
parents:
diff changeset
   471
! !
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   472
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   473
!NonPositionableExternalStream methodsFor:'queries'!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   474
5851
6823cc642d60 only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
   475
atEnd
6823cc642d60 only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
   476
    "return true, if position is at end"
6823cc642d60 only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
   477
5918
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
   478
    (self == StdInStream) ifTrue:[
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
   479
	OperatingSystem hasConsole ifFalse:[
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
   480
	    ^ true
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
   481
	]
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
   482
    ].
0d8bc97e7106 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5851
diff changeset
   483
5851
6823cc642d60 only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
   484
    "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
   485
     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
   486
6823cc642d60 only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
   487
    self readWait.
6823cc642d60 only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
   488
    ^ super atEnd.
6823cc642d60 only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
   489
!
6823cc642d60 only do readWait for pipes and sockets.
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
   490
4962
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   491
current
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   492
    "for compatibility with Transcript - allow Transcript current,
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   493
     even if redirected to the standardError"
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   494
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   495
    self == Transcript ifTrue:[
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   496
	^ self
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   497
    ].
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   498
    ^ super current
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   499
!
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   500
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   501
isPositionable
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   502
    "return true, if the stream supports positioning (this one is not)"
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   503
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4962
diff changeset
   504
    ^ false
11455
c78421a80b7c changed #size: raise error
Stefan Vogel <sv@exept.de>
parents: 10410
diff changeset
   505
!
c78421a80b7c changed #size: raise error
Stefan Vogel <sv@exept.de>
parents: 10410
diff changeset
   506
17734
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17732
diff changeset
   507
size
11455
c78421a80b7c changed #size: raise error
Stefan Vogel <sv@exept.de>
parents: 10410
diff changeset
   508
    "we do not know our size"
c78421a80b7c changed #size: raise error
Stefan Vogel <sv@exept.de>
parents: 10410
diff changeset
   509
c78421a80b7c changed #size: raise error
Stefan Vogel <sv@exept.de>
parents: 10410
diff changeset
   510
    ^ self positionError
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   511
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   512
10349
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   513
!NonPositionableExternalStream methodsFor:'reading'!
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
nextOrNil
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   516
    "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
   517
     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
   518
     Instead, nil is returned immediately.
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   519
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   520
     Redefined, to wait on pipes and sockets"
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   521
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   522
    self atEnd ifTrue:[^ nil].
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   523
    ^ self next
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   524
!
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
peekOrNil
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   527
    "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
   528
     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
   529
     Instead, nil is returned immediately.
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   530
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   531
     Redefined, to wait on pipes and sockets"
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   532
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   533
    self atEnd ifTrue:[^ nil].
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   534
    ^ self peek
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   535
! !
cbfa00bba11d Speedup ExternalStream>>#nextOrNil and ExternalStream>>#peekOrNil.
Stefan Vogel <sv@exept.de>
parents: 10327
diff changeset
   536
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   537
!NonPositionableExternalStream methodsFor:'writing'!
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   538
7679
4c1f76483b6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7541
diff changeset
   539
nextPutBytes:initialWriteCount from:buffer startingAt:initialOffset
4c1f76483b6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7541
diff changeset
   540
    "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
   541
7682
5d43745f59ac only do a writeWait if previous non-blocking write failed to
Claus Gittinger <cg@exept.de>
parents: 7679
diff changeset
   542
    |count offset remaining wasBlocking|
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   543
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   544
    offset := initialOffset.
7679
4c1f76483b6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7541
diff changeset
   545
    remaining := initialWriteCount.
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   546
7679
4c1f76483b6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7541
diff changeset
   547
    wasBlocking := self blocking:false.
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   548
    [remaining ~~ 0] whileTrue:[
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   549
	count := super nextPutBytes:remaining from:buffer startingAt:offset.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   550
	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
   551
10327
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   552
	remaining := remaining - count.
c7bb805fa32c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8815
diff changeset
   553
	offset := offset + count.
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   554
    ].
7679
4c1f76483b6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7541
diff changeset
   555
    wasBlocking ifTrue:[self blocking:true].
4c1f76483b6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7541
diff changeset
   556
7497
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   557
    ^ offset - initialOffset.
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   558
! !
cc29afd51151 Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents: 7241
diff changeset
   559
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   560
!NonPositionableExternalStream class methodsFor:'documentation'!
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   561
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   562
version
17834
04ff72c5039a Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17814
diff changeset
   563
    ^ '$Id: NonPositionableExternalStream.st 10632 2011-04-09 17:19:04Z vranyj1 $'
17751
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   564
!
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   565
b2273fa8d59f Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17734
diff changeset
   566
version_CVS
17834
04ff72c5039a Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17814
diff changeset
   567
    ^ 'Header: /var/local/cvs/stx/libbasic/NonPositionableExternalStream.st,v 1.61 2010-03-04 15:11:43 stefan Exp '
17761
b0e5971141bc Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17754
diff changeset
   568
!
17734
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17732
diff changeset
   569
17761
b0e5971141bc Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17754
diff changeset
   570
version_SVN
17834
04ff72c5039a Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17814
diff changeset
   571
    ^ '$Id: NonPositionableExternalStream.st 10632 2011-04-09 17:19:04Z vranyj1 $'
17761
b0e5971141bc Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17754
diff changeset
   572
! !
17767
a4a32df3aa5e merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17761
diff changeset
   573
17772
6e0b3c06c364 Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17767
diff changeset
   574
17780
b6e42c92eba0 Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17772
diff changeset
   575
17807
06cc6c49e291 merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17780
diff changeset
   576
17814
b75a7f0c346b Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17807
diff changeset
   577
17834
04ff72c5039a Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17814
diff changeset
   578