... |
... |
@@ -26,6 +26,12 @@ |
26
|
26
|
Stream. Class FUNDAMENTAL-CHARACTER-STREAM provides a default method
|
27
|
27
|
which returns CHARACTER."))
|
28
|
28
|
|
|
29
|
+(defgeneric (setf stream-element-type) (new-value stream)
|
|
30
|
+ (:documentation
|
|
31
|
+ _N"Set the type specifier of the kind of object returned by the
|
|
32
|
+ STREAM. There is no default method as this is optional and only
|
|
33
|
+ needed for bivalent streams."))
|
|
34
|
+
|
29
|
35
|
(defmethod stream-element-type ((stream lisp-stream))
|
30
|
36
|
(funcall (lisp-stream-misc stream) stream :element-type))
|
31
|
37
|
|
... |
... |
@@ -48,7 +54,7 @@ |
48
|
54
|
(not (eq (lisp-stream-in stream) #'closed-flame)))
|
49
|
55
|
|
50
|
56
|
(defmethod pcl-open-stream-p ((stream fundamental-stream))
|
51
|
|
- nil)
|
|
57
|
+ (stream-open-p stream))
|
52
|
58
|
|
53
|
59
|
(when (find-class 'stream:simple-stream nil)
|
54
|
60
|
(defmethod pcl-open-stream-p ((stream stream:simple-stream))
|
... |
... |
@@ -71,6 +77,11 @@ |
71
|
77
|
(funcall (lisp-stream-misc stream) stream :close abort))
|
72
|
78
|
t)
|
73
|
79
|
|
|
80
|
+(defmethod pcl-close ((stream fundamental-stream) &key abort)
|
|
81
|
+ (declare (ignore abort))
|
|
82
|
+ (setf (stream-open-p stream) nil)
|
|
83
|
+ t)
|
|
84
|
+
|
74
|
85
|
(when (find-class 'stream:simple-stream nil)
|
75
|
86
|
(defmethod pcl-close ((stream stream:simple-stream) &key abort)
|
76
|
87
|
(stream:device-close stream abort)))
|
... |
... |
@@ -85,6 +96,10 @@ |
85
|
96
|
(defgeneric input-stream-p (stream)
|
86
|
97
|
(:documentation _N"Returns non-nil if the given Stream can perform input operations."))
|
87
|
98
|
|
|
99
|
+(defmethod input-stream-p (stream)
|
|
100
|
+ (declare (ignore stream))
|
|
101
|
+ nil)
|
|
102
|
+
|
88
|
103
|
(defmethod input-stream-p ((stream lisp-stream))
|
89
|
104
|
(and (not (eq (lisp-stream-in stream) #'closed-flame))
|
90
|
105
|
(or (not (eq (lisp-stream-in stream) #'ill-in))
|
... |
... |
@@ -105,6 +120,10 @@ |
105
|
120
|
(defgeneric output-stream-p (stream)
|
106
|
121
|
(:documentation _N"Returns non-nil if the given Stream can perform output operations."))
|
107
|
122
|
|
|
123
|
+(defmethod output-stream-p (stream)
|
|
124
|
+ (declare (ignore stream))
|
|
125
|
+ nil)
|
|
126
|
+
|
108
|
127
|
(defmethod output-stream-p ((stream lisp-stream))
|
109
|
128
|
(and (not (eq (lisp-stream-in stream) #'closed-flame))
|
110
|
129
|
(or (not (eq (lisp-stream-out stream) #'ill-out))
|
... |
... |
@@ -117,6 +136,30 @@ |
117
|
136
|
(defmethod output-stream-p ((stream stream:simple-stream))
|
118
|
137
|
(stream::%output-stream-p stream)))
|
119
|
138
|
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+(defgeneric pcl-pathname (pathspec)
|
|
142
|
+ (:documentation _N"Convert pathspec (a pathname, string or stream) into a pathname."))
|
|
143
|
+
|
|
144
|
+(let ((func #'pathname))
|
|
145
|
+ (defmethod pcl-pathname (pathspec)
|
|
146
|
+ (funcall func pathspec)))
|
|
147
|
+
|
|
148
|
+(setf (fdefinition 'pathname) #'pcl-pathname)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+(defgeneric pcl-truename (filespec)
|
|
153
|
+ (:documentation _N"Return the pathname for the actual file described by the filespec.
|
|
154
|
+ An error of type file-error is signalled if no such file exists,
|
|
155
|
+ or the pathname is wild."))
|
|
156
|
+
|
|
157
|
+(let ((func #'truename))
|
|
158
|
+ (defmethod pcl-truename (filespec)
|
|
159
|
+ (funcall func filespec)))
|
|
160
|
+
|
|
161
|
+(setf (fdefinition 'truename) #'pcl-truename)
|
|
162
|
+
|
120
|
163
|
|
121
|
164
|
;;; Character input streams.
|
122
|
165
|
;;;
|
... |
... |
@@ -205,13 +248,43 @@ |
205
|
248
|
_N"Implements CLEAR-INPUT for the stream, returning NIL. The default
|
206
|
249
|
method does nothing."))
|
207
|
250
|
|
208
|
|
-(defmethod stream-clear-input ((stream fundamental-character-input-stream))
|
|
251
|
+(defmethod stream-clear-input ((stream fundamental-input-stream))
|
209
|
252
|
nil)
|
210
|
253
|
|
211
|
254
|
(defgeneric stream-read-sequence (stream seq &optional start end)
|
212
|
255
|
(:documentation
|
213
|
256
|
_N"Implements READ-SEQUENCE for the stream."))
|
214
|
257
|
|
|
258
|
+(defmethod stream-read-sequence
|
|
259
|
+ ((stream fundamental-character-input-stream) sequence &optional start end)
|
|
260
|
+ (prog ((pos (or start 0))
|
|
261
|
+ (end (or end (length sequence)))
|
|
262
|
+ value)
|
|
263
|
+ (declare (fixnum pos end))
|
|
264
|
+ next
|
|
265
|
+ (when (< pos end)
|
|
266
|
+ (setf value (stream-read-char stream))
|
|
267
|
+ (unless (eq value :eof)
|
|
268
|
+ (setf (elt sequence pos) value)
|
|
269
|
+ (incf pos)
|
|
270
|
+ (go next)))
|
|
271
|
+ (return pos)))
|
|
272
|
+
|
|
273
|
+(defmethod stream-read-sequence
|
|
274
|
+ ((stream fundamental-binary-input-stream) sequence &optional start end)
|
|
275
|
+ (prog ((pos (or start 0))
|
|
276
|
+ (end (or end (length sequence)))
|
|
277
|
+ value)
|
|
278
|
+ (declare (fixnum pos end))
|
|
279
|
+ next
|
|
280
|
+ (when (< pos end)
|
|
281
|
+ (setf value (stream-read-byte stream))
|
|
282
|
+ (unless (eq value :eof)
|
|
283
|
+ (setf (elt sequence pos) value)
|
|
284
|
+ (incf pos)
|
|
285
|
+ (go next)))
|
|
286
|
+ (return pos)))
|
|
287
|
+
|
215
|
288
|
|
216
|
289
|
;;; Character output streams.
|
217
|
290
|
;;;
|
... |
... |
@@ -350,6 +423,30 @@ |
350
|
423
|
(:documentation
|
351
|
424
|
_N"Implements WRITE-SEQUENCE for the stream."))
|
352
|
425
|
|
|
426
|
+(defmethod stream-write-sequence
|
|
427
|
+ ((stream fundamental-character-output-stream) sequence &optional start end)
|
|
428
|
+ (prog ((pos (or start 0))
|
|
429
|
+ (end (or end (length sequence))))
|
|
430
|
+ (declare (fixnum pos end))
|
|
431
|
+ next
|
|
432
|
+ (when (< pos end)
|
|
433
|
+ (stream-write-char stream (elt sequence pos))
|
|
434
|
+ (incf pos)
|
|
435
|
+ (go next)))
|
|
436
|
+ sequence)
|
|
437
|
+
|
|
438
|
+(defmethod stream-write-sequence
|
|
439
|
+ ((stream fundamental-binary-output-stream) sequence &optional start end)
|
|
440
|
+ (prog ((pos (or start 0))
|
|
441
|
+ (end (or end (length sequence))))
|
|
442
|
+ (declare (fixnum pos end))
|
|
443
|
+ next
|
|
444
|
+ (when (< pos end)
|
|
445
|
+ (stream-write-byte stream (elt sequence pos))
|
|
446
|
+ (incf pos)
|
|
447
|
+ (go next)))
|
|
448
|
+ sequence)
|
|
449
|
+
|
353
|
450
|
(defgeneric stream-file-position (stream)
|
354
|
451
|
(:documentation
|
355
|
452
|
_N"Implements FILE-POSITION for the stream."))
|