@@ -4,15 +4,16 @@ OSSAttachableFileStream represents a stream on an input or output channel provi
4
4
The most common use is to represent either the read or write end of a Pipe from the Operatying System . This way, it provides a Stream API for both, reading and writing. An OSSPipe contains a 'reader' and a 'writer' which will be two different instances of this class.
5
5
"
6
6
Class {
7
- #name : # OSSAttachableFileStream ,
8
- #superclass : # OldStandardFileStream ,
7
+ #name : ' OSSAttachableFileStream' ,
8
+ #superclass : ' OldStandardFileStream' ,
9
9
#instVars : [
10
10
' autoClose'
11
11
],
12
- #category : ' OSSubprocess'
12
+ #category : ' OSSubprocess' ,
13
+ #package : ' OSSubprocess'
13
14
}
14
15
15
- { #category : # ' file creation' }
16
+ { #category : ' file creation' }
16
17
OSSAttachableFileStream class >> fileNamed: fileName [
17
18
" Since this is an attacheable stream it means the underlying stream in the OS
18
19
has already been opened"
@@ -21,7 +22,7 @@ OSSAttachableFileStream class >> fileNamed: fileName [
21
22
22
23
]
23
24
24
- { #category : # ' file creation' }
25
+ { #category : ' file creation' }
25
26
OSSAttachableFileStream class >> isAFileNamed: fileName [
26
27
" Since this is an attacheable stream it means the underlying stream in the OS
27
28
has already been opened"
@@ -30,7 +31,7 @@ OSSAttachableFileStream class >> isAFileNamed: fileName [
30
31
31
32
]
32
33
33
- { #category : # ' instance creation' }
34
+ { #category : ' instance creation' }
34
35
OSSAttachableFileStream class >> name: aSymbolOrString attachTo: aFileID writable: readWriteFlag [
35
36
" Create a new instance attached to aFileID. For write streams, this represents two
36
37
Smalltalk streams which write to the same OS file or output stream,
@@ -44,7 +45,7 @@ OSSAttachableFileStream class >> name: aSymbolOrString attachTo: aFileID writabl
44
45
writable: readWriteFlag) initialize
45
46
]
46
47
47
- { #category : # ' TO USE LATER WITHOUT OSPROCESS' }
48
+ { #category : ' TO USE LATER WITHOUT OSPROCESS' }
48
49
OSSAttachableFileStream class >> name: aSymbolOrString attachToCFile: aCFile writable: readWriteFlag [
49
50
" Create a new instance attached to aCFile. For write streams, this represents two
50
51
Smalltalk streams which write to the same OS file or output stream,
@@ -58,7 +59,7 @@ OSSAttachableFileStream class >> name: aSymbolOrString attachToCFile: aCFile wri
58
59
writable: readWriteFlag) initialize
59
60
]
60
61
61
- { #category : # ' file creation' }
62
+ { #category : ' file creation' }
62
63
OSSAttachableFileStream class >> newFileNamed: fileName [
63
64
" Since this is an attacheable stream it means the underlying stream in the OS
64
65
has already been opened"
@@ -67,7 +68,7 @@ OSSAttachableFileStream class >> newFileNamed: fileName [
67
68
68
69
]
69
70
70
- { #category : # ' file creation' }
71
+ { #category : ' file creation' }
71
72
OSSAttachableFileStream class >> oldFileNamed: fileName [
72
73
" Since this is an attacheable stream it means the underlying stream in the OS
73
74
has already been opened"
@@ -76,7 +77,7 @@ OSSAttachableFileStream class >> oldFileNamed: fileName [
76
77
77
78
]
78
79
79
- { #category : # ' file creation' }
80
+ { #category : ' file creation' }
80
81
OSSAttachableFileStream class >> readOnlyFileNamed: fileName [
81
82
" Since this is an attacheable stream it means the underlying stream in the OS
82
83
has already been opened"
@@ -85,7 +86,7 @@ OSSAttachableFileStream class >> readOnlyFileNamed: fileName [
85
86
86
87
]
87
88
88
- { #category : # registry }
89
+ { #category : ' registry' }
89
90
OSSAttachableFileStream class >> register: anObject [
90
91
" An attachable file stream is generally either a second reference to an
91
92
existing file stream, or a reference to a transient object such as a pipe
@@ -94,7 +95,7 @@ OSSAttachableFileStream class >> register: anObject [
94
95
^ anObject
95
96
]
96
97
97
- { #category : # registry }
98
+ { #category : ' registry' }
98
99
OSSAttachableFileStream class >> unregister: anObject [
99
100
" An attachable file stream is generally either a second reference to an
100
101
existing file stream, or a reference to a transient object such as a pipe
@@ -103,14 +104,14 @@ OSSAttachableFileStream class >> unregister: anObject [
103
104
^ anObject
104
105
]
105
106
106
- { #category : # converting }
107
+ { #category : ' converting' }
107
108
OSSAttachableFileStream >> asAttachableFileStream [
108
109
109
110
^ self
110
111
111
112
]
112
113
113
- { #category : # finalization }
114
+ { #category : ' finalization' }
114
115
OSSAttachableFileStream >> autoClose [
115
116
" Private. Answer true if the file should be automatically closed when
116
117
this object is finalized."
@@ -119,7 +120,7 @@ OSSAttachableFileStream >> autoClose [
119
120
ifNil: [autoClose := true ]
120
121
]
121
122
122
- { #category : # ' open/close' }
123
+ { #category : ' open/close' }
123
124
OSSAttachableFileStream >> close [
124
125
" Close this file."
125
126
@@ -132,7 +133,7 @@ OSSAttachableFileStream >> close [
132
133
133
134
]
134
135
135
- { #category : # ' open/close' }
136
+ { #category : ' open/close' }
136
137
OSSAttachableFileStream >> ensureOpen [
137
138
" Since this is an attacheable stream it means the underlying stream in the OS
138
139
has already been opened"
@@ -141,30 +142,30 @@ OSSAttachableFileStream >> ensureOpen [
141
142
142
143
]
143
144
144
- { #category : # finalization }
145
+ { #category : ' finalization' }
145
146
OSSAttachableFileStream >> finalize [
146
147
" If #autoClose is true, then we try to close the stream upon finalization - GC "
147
148
148
149
self autoClose
149
150
ifTrue: [[self primCloseNoError: fileID] on: Error do: []]
150
151
]
151
152
152
- { #category : # ' read, write, position' }
153
+ { #category : ' read, write, position' }
153
154
OSSAttachableFileStream >> flush [
154
155
" Flush the external OS stream (the one in the C library)."
155
156
156
157
self systemAccessor fflush: self getFilePointerAsCFile
157
158
]
158
159
159
- { #category : # finalization }
160
+ { #category : ' finalization' }
160
161
OSSAttachableFileStream >> keepOpen [
161
162
" Do not allow the file to be closed when this object is finalized."
162
163
163
164
autoClose := false
164
165
165
166
]
166
167
167
- { #category : # attaching }
168
+ { #category : ' attaching' }
168
169
OSSAttachableFileStream >> name: aSymbolOrString attachTo: aFileID writable: readWriteFlag [
169
170
" Attach to an existing file handle, assumed to have been previously
170
171
opened by the underlying operating system.
@@ -179,7 +180,7 @@ OSSAttachableFileStream >> name: aSymbolOrString attachTo: aFileID writable: rea
179
180
180
181
]
181
182
182
- { #category : # ' TO USE LATER WITHOUT OSPROCESS' }
183
+ { #category : ' TO USE LATER WITHOUT OSPROCESS' }
183
184
OSSAttachableFileStream >> name: aSymbolOrString attachToCFile: externalFilePointer writable: readWriteFlag [
184
185
" Attach to an existing file handle, assumed to have been previously opened by the underlying operating system.
185
186
We assume a 32 bits machine and here we document the SQFile used by the VM:
@@ -223,7 +224,7 @@ typedef struct {
223
224
224
225
]
225
226
226
- { #category : # ' TO USE LATER WITHOUT OSPROCESS' }
227
+ { #category : ' TO USE LATER WITHOUT OSPROCESS' }
227
228
OSSAttachableFileStream >> oldname: aSymbolOrString attachTo: externalFilePointer writable: readWriteFlag [
228
229
" Attach to an existing file handle, assumed to have been previously opened by the underlying operating system.
229
230
We assume a 32 bits machine and here we document the SQFile used by the VM:
@@ -259,7 +260,7 @@ typedef struct {
259
260
260
261
]
261
262
262
- { #category : # ' open/close' }
263
+ { #category : ' open/close' }
263
264
OSSAttachableFileStream >> open [
264
265
" Since this is an attacheable stream it means the underlying stream in the OS
265
266
has already been opened"
@@ -268,7 +269,7 @@ OSSAttachableFileStream >> open [
268
269
269
270
]
270
271
271
- { #category : # ' open/close' }
272
+ { #category : ' open/close' }
272
273
OSSAttachableFileStream >> open: fileName forWrite: writeMode [
273
274
" Since this is an attacheable stream it means the underlying stream in the OS
274
275
has already been opened"
@@ -277,7 +278,7 @@ OSSAttachableFileStream >> open: fileName forWrite: writeMode [
277
278
278
279
]
279
280
280
- { #category : # ' open/close' }
281
+ { #category : ' open/close' }
281
282
OSSAttachableFileStream >> openReadOnly [
282
283
" Since this is an attacheable stream it means the underlying stream in the OS
283
284
has already been opened"
@@ -286,7 +287,7 @@ OSSAttachableFileStream >> openReadOnly [
286
287
287
288
]
288
289
289
- { #category : # ' read, write, position' }
290
+ { #category : ' read, write, position' }
290
291
OSSAttachableFileStream >> position [
291
292
" Return the receiver's current file position. If the stream is not positionable,
292
293
as in the case of a Unix pipe stream, answer 0."
@@ -297,7 +298,7 @@ OSSAttachableFileStream >> position [
297
298
298
299
]
299
300
300
- { #category : # ' open/close' }
301
+ { #category : ' open/close' }
301
302
OSSAttachableFileStream >> reopen [
302
303
" Since this is an attacheable stream it means the underlying stream in the OS
303
304
has already been opened"
@@ -306,28 +307,28 @@ OSSAttachableFileStream >> reopen [
306
307
307
308
]
308
309
309
- { #category : # ' non blocking' }
310
+ { #category : ' non blocking' }
310
311
OSSAttachableFileStream >> setNonBlocking [
311
312
" Make this stream to be none blocking. In Linux it means
312
313
calling fcntl() to set the file non-blocking (O_NONBLOCK)."
313
314
314
315
self systemAccessor makeFileNoneBocking: fileID
315
316
]
316
317
317
- { #category : # ' TO USE LATER WITHOUT OSPROCESS' }
318
+ { #category : ' TO USE LATER WITHOUT OSPROCESS' }
318
319
OSSAttachableFileStream >> setOSFilePointerFromByteArray: externalFilePointer to: aDestByteArray offset: anOffsetNumber [
319
320
1 to: 4 do: [ :index | aDestByteArray at: (index + anOffsetNumber) put: (externalFilePointer at: index) ]
320
321
321
322
]
322
323
323
- { #category : # ' TO USE LATER WITHOUT OSPROCESS' }
324
+ { #category : ' TO USE LATER WITHOUT OSPROCESS' }
324
325
OSSAttachableFileStream >> setSessionIDTo: fileIDByteArray [
325
326
| currentSession |
326
327
currentSession := OSSVMProcess vmProcess sessionID.
327
328
1 to: currentSession size do: [ :index | fileIDByteArray at: index put: (currentSession at: index) ]
328
329
]
329
330
330
- { #category : # ' read, write, position' }
331
+ { #category : ' read, write, position' }
331
332
OSSAttachableFileStream >> upToEnd [
332
333
" Answer a subcollection from the current access position through the last element
333
334
of the receiver. This is slower than the method in StandardFileStream, but it
0 commit comments