1
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1989-92 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
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 |
"
|
|
12 |
|
|
13 |
ExternalStream subclass:#NonPositionableExternalStream
|
|
14 |
instanceVariableNames:'typeIfStandard'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Streams-External'
|
|
18 |
!
|
|
19 |
|
|
20 |
NonPositionableExternalStream comment:'
|
|
21 |
|
|
22 |
COPYRIGHT (c) 1989-92 by Claus Gittinger
|
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
this one stands all non-positionable external streams; there are
|
|
26 |
terminal streams, pipe streams etc.
|
|
27 |
|
|
28 |
%W% %E%
|
|
29 |
'!
|
|
30 |
|
|
31 |
%{
|
|
32 |
#include <stdio.h>
|
|
33 |
%}
|
|
34 |
|
|
35 |
!NonPositionableExternalStream class methodsFor:'instance creation'!
|
|
36 |
|
|
37 |
forStdin
|
|
38 |
^ self basicNew initializeForStdin
|
|
39 |
!
|
|
40 |
|
|
41 |
forStdout
|
|
42 |
^ self basicNew initializeForStdout
|
|
43 |
!
|
|
44 |
|
|
45 |
forStderr
|
|
46 |
^ self basicNew initializeForStderr
|
|
47 |
! !
|
|
48 |
|
|
49 |
!NonPositionableExternalStream methodsFor:'private'!
|
|
50 |
|
|
51 |
initializeForStdin
|
|
52 |
mode := #readonly.
|
|
53 |
typeIfStandard := #Stdin.
|
|
54 |
%{
|
|
55 |
_INST(filePointer) = MKOBJ(stdin);
|
|
56 |
%}
|
|
57 |
!
|
|
58 |
|
|
59 |
initializeForStdout
|
|
60 |
mode := #readwrite.
|
|
61 |
unBuffered := true.
|
|
62 |
typeIfStandard := #Stdout.
|
|
63 |
%{
|
|
64 |
_INST(filePointer) = MKOBJ(stdout);
|
|
65 |
%}
|
|
66 |
!
|
|
67 |
|
|
68 |
initializeForStderr
|
|
69 |
mode := #readwrite.
|
|
70 |
unBuffered := true.
|
|
71 |
typeIfStandard := #Stderr.
|
|
72 |
%{
|
|
73 |
_INST(filePointer) = MKOBJ(stderr);
|
|
74 |
%}
|
|
75 |
!
|
|
76 |
|
|
77 |
reOpen
|
|
78 |
"if I am one of the standard streams, reopen is easy"
|
|
79 |
|
|
80 |
'reopen NPExtStr' printNewline.
|
|
81 |
(typeIfStandard == #Stdin) ifTrue:[
|
|
82 |
^ self initializeForStdin
|
|
83 |
].
|
|
84 |
(typeIfStandard == #Stdout) ifTrue:[
|
|
85 |
^ self initializeForStdout
|
|
86 |
].
|
|
87 |
(typeIfStandard == #Stderr) ifTrue:[
|
|
88 |
^ self initializeForStderr
|
|
89 |
].
|
|
90 |
^ super reOpen
|
|
91 |
! !
|
|
92 |
|
|
93 |
!NonPositionableExternalStream methodsFor:'error handling'!
|
|
94 |
|
|
95 |
errorNotPositionable
|
|
96 |
^ self error:'positioning not allowd'
|
|
97 |
! !
|
|
98 |
|
|
99 |
!NonPositionableExternalStream methodsFor:'positioning'!
|
|
100 |
|
|
101 |
position
|
|
102 |
^ 0
|
|
103 |
!
|
|
104 |
|
|
105 |
position:anInteger
|
|
106 |
self errorNotPositionable
|
|
107 |
! !
|