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