78
|
1 |
"{ Package: 'stx:goodies/xtreams/terminals' }"
|
|
2 |
|
|
3 |
!
|
|
4 |
|
|
5 |
!Block methodsFor:'converting'!
|
39
|
6 |
|
78
|
7 |
reading
|
|
8 |
self numArgs = 0 ifTrue: [^Xtreams::BlockClosureReadStream on: self].
|
|
9 |
self numArgs = 1 ifTrue: [^Xtreams::BlockClosureGenerateStream on: self].
|
|
10 |
self error: 'More arguments than we can poke a stick at!!'
|
|
11 |
! !
|
|
12 |
!Block methodsFor:'converting'!
|
|
13 |
|
|
14 |
writing
|
|
15 |
self numArgs = 1 ifTrue: [^Xtreams::BlockClosureWriteStream on: self].
|
|
16 |
self error: 'Must be a single argument block.'
|
|
17 |
! !
|
|
18 |
!Collection methodsFor:'converting'!
|
39
|
19 |
|
|
20 |
writing
|
78
|
21 |
^Xtreams::CollectionWriteStream on: self
|
|
22 |
! !
|
|
23 |
!Filename methodsFor:'converting'!
|
|
24 |
|
|
25 |
appending
|
|
26 |
^(OperatingSystem open: self osNameForAccess attributes: #(O_APPEND O_CREAT) mode: nil) writing
|
|
27 |
position: self fileSize;
|
|
28 |
isPositionable: false;
|
|
29 |
yourself
|
39
|
30 |
! !
|
78
|
31 |
!Filename methodsFor:'converting'!
|
39
|
32 |
|
78
|
33 |
reading
|
|
34 |
self isDirectory ifFalse: [^(OperatingSystem open: self osNameForAccess attributes: #(O_RDONLY) mode: nil) reading].
|
|
35 |
|
|
36 |
"Return the directory contents as a stream of filenames"
|
|
37 |
^([self directoryContents]
|
|
38 |
on: Error
|
|
39 |
do: [:ex | ex return: #()])
|
|
40 |
reading collecting: [:each | self construct: each asFilename]
|
|
41 |
! !
|
|
42 |
!Filename methodsFor:'converting'!
|
|
43 |
|
|
44 |
writing
|
|
45 |
^(OperatingSystem open: self osNameForAccess attributes: #(O_WRONLY | O_CREAT) mode: nil) writing
|
|
46 |
! !
|
|
47 |
!PipeStream methodsFor:'testing'!
|
|
48 |
|
|
49 |
isActive
|
|
50 |
|
|
51 |
^self isOpen
|
|
52 |
! !
|
43
|
53 |
!PipeStream methodsFor:'converting'!
|
|
54 |
|
|
55 |
reading
|
|
56 |
|
|
57 |
^Xtreams::ExternalReadStream on: self
|
|
58 |
! !
|
|
59 |
!PipeStream methodsFor:'converting'!
|
9
|
60 |
|
43
|
61 |
writing
|
|
62 |
|
|
63 |
^Xtreams::ExternalWriteStream on: self
|
|
64 |
! !
|
78
|
65 |
!Random methodsFor:'converting'!
|
43
|
66 |
|
78
|
67 |
reading
|
|
68 |
^[self next] reading
|
|
69 |
contentsSpecies: self contentsSpecies;
|
|
70 |
yourself
|
39
|
71 |
! !
|
78
|
72 |
!SequenceableCollection methodsFor:'converting'!
|
9
|
73 |
|
|
74 |
reading
|
78
|
75 |
^Xtreams::SequenceableCollectionReadStream on: self
|
9
|
76 |
! !
|
78
|
77 |
!SequenceableCollection methodsFor:'converting'!
|
9
|
78 |
|
|
79 |
writing
|
78
|
80 |
^Xtreams::SequenceableCollectionWriteStream on: self
|
9
|
81 |
! !
|
78
|
82 |
!SharedQueue methodsFor:'converting'!
|
9
|
83 |
|
78
|
84 |
reading
|
|
85 |
^Xtreams::SharedQueueReadStream on: self
|
|
86 |
! !
|
|
87 |
!SharedQueue methodsFor:'converting'!
|
|
88 |
|
|
89 |
writing
|
|
90 |
^Xtreams::SharedQueueWriteStream on: self
|
|
91 |
! !
|
9
|
92 |
!Socket methodsFor:'converting'!
|
|
93 |
|
|
94 |
accepting
|
|
95 |
"Return a read stream that produces new sockets from incoming connections."
|
|
96 |
|
|
97 |
"^ ReadStream"
|
|
98 |
|
|
99 |
"Listen for connections and close those connections immediately.
|
|
100 |
| socket |
|
|
101 |
socket := SocketAccessor newTCP.
|
|
102 |
socket listenFor: 1.
|
|
103 |
[socket acceping do: [:client | client close]]
|
|
104 |
ensure: [socket close]
|
|
105 |
"
|
|
106 |
|
|
107 |
^[self accept] reading
|
|
108 |
closeBlock: [self close];
|
|
109 |
yourself
|
|
110 |
! !
|
|
111 |
!Socket methodsFor:'converting'!
|
|
112 |
|
|
113 |
reading
|
39
|
114 |
^Xtreams::ExternalReadStream on: self
|
9
|
115 |
! !
|
|
116 |
!Socket methodsFor:'converting'!
|
|
117 |
|
|
118 |
writing
|
39
|
119 |
^Xtreams::ExternalWriteStream on: self
|
|
120 |
! !
|
78
|
121 |
!TextCollector methodsFor:'converting'!
|
39
|
122 |
|
|
123 |
writing
|
78
|
124 |
^[:object | self nextPut: object] writing
|
39
|
125 |
! !
|
78
|
126 |
!UndefinedObject methodsFor:'converting'!
|
39
|
127 |
|
78
|
128 |
writing
|
|
129 |
^Xtreams::NullWriteStream new
|
9
|
130 |
! !
|
78
|
131 |
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'xtreams'!
|
39
|
132 |
|
|
133 |
reading
|
|
134 |
|
78
|
135 |
^Xtreams::FileReadStream on: self
|
39
|
136 |
! !
|
|
137 |
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'xtreams'!
|
|
138 |
|
|
139 |
writing
|
|
140 |
|
|
141 |
^Xtreams::FileWriteStream on: self
|
|
142 |
! !
|
43
|
143 |
!Xtreams::Buffer methodsFor:'converting'!
|
|
144 |
|
|
145 |
reading
|
|
146 |
^BufferReadStream on: self
|
|
147 |
! !
|
|
148 |
!Xtreams::Buffer methodsFor:'converting'!
|
|
149 |
|
|
150 |
writing
|
|
151 |
^BufferWriteStream on: self
|
|
152 |
! !
|
78
|
153 |
!stx_goodies_xtreams_terminals class methodsFor:'documentation'!
|
43
|
154 |
|
78
|
155 |
extensionsVersion_SVN
|
|
156 |
^ '$Id$'
|
43
|
157 |
! !
|