1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
1
|
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:#FileStream
|
|
14 |
instanceVariableNames:'pathName'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Streams-External'
|
|
18 |
!
|
|
19 |
|
|
20 |
FileStream comment:'
|
5
|
21 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
1
|
22 |
All Rights Reserved
|
88
|
23 |
'!
|
1
|
24 |
|
88
|
25 |
!FileStream class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
30 |
All Rights Reserved
|
1
|
31 |
|
88
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
!
|
|
40 |
|
|
41 |
version
|
|
42 |
"
|
|
43 |
$Header: /cvs/stx/stx/libbasic/FileStream.st,v 1.13 1994-06-02 16:20:18 claus Exp $
|
|
44 |
"
|
|
45 |
!
|
|
46 |
|
|
47 |
documentation
|
|
48 |
"
|
|
49 |
This class provides access to the operating systems underlying file
|
|
50 |
system (i.e. its an interface to the stdio library).
|
|
51 |
"
|
|
52 |
! !
|
1
|
53 |
|
|
54 |
%{
|
|
55 |
#include <stdio.h>
|
10
|
56 |
#include <errno.h>
|
1
|
57 |
|
|
58 |
#ifdef transputer
|
|
59 |
# include <iocntrl.h>
|
|
60 |
# ifndef fileno
|
|
61 |
/* kludge: inmos forgot fileno */
|
|
62 |
# define fileno(f) ((f)->__file)
|
|
63 |
# endif
|
|
64 |
#else
|
|
65 |
# include <sys/types.h>
|
|
66 |
# include <sys/stat.h>
|
|
67 |
#endif
|
10
|
68 |
|
42
|
69 |
#ifdef hpux
|
68
|
70 |
# define fileno(f) ((f->__fileH << 8) | (f->__fileL))
|
42
|
71 |
#endif
|
|
72 |
|
10
|
73 |
#ifndef SEEK_SET
|
13
|
74 |
# define SEEK_SET 0
|
10
|
75 |
#endif
|
|
76 |
#ifndef SEEK_CUR
|
13
|
77 |
# define SEEK_CUR 1
|
10
|
78 |
#endif
|
|
79 |
#ifndef SEEK_END
|
13
|
80 |
# define SEEK_END 2
|
10
|
81 |
#endif
|
|
82 |
|
1
|
83 |
%}
|
|
84 |
|
|
85 |
!FileStream class methodsFor:'instance creation'!
|
|
86 |
|
|
87 |
newFileNamed:filename
|
|
88 |
"return a FileStream for new file named filename, aString.
|
|
89 |
If the file exists, it is truncated, otherwise created.
|
|
90 |
The file is opened for write access only."
|
|
91 |
|
|
92 |
|newStream|
|
2
|
93 |
newStream := self new pathName:filename.
|
77
|
94 |
newStream createForReadWrite isNil ifTrue:[^nil].
|
1
|
95 |
^ newStream
|
|
96 |
!
|
|
97 |
|
|
98 |
newFileNamed:filename in:aDirectory
|
|
99 |
"return a FileStream for new file named filename, aString
|
|
100 |
in aDirectory, a FileDirectory.
|
|
101 |
If the file exists, it is truncated, otherwise created.
|
|
102 |
The file is opened for write access only."
|
|
103 |
|
|
104 |
|newStream|
|
2
|
105 |
newStream := self new pathName:filename in:aDirectory.
|
77
|
106 |
newStream createForReadWrite isNil ifTrue:[^nil].
|
1
|
107 |
^ newStream
|
|
108 |
!
|
|
109 |
|
|
110 |
oldFileNamed:filename
|
|
111 |
"return a FileStream for existing file named filename, aString.
|
|
112 |
The file is opened for read/write access."
|
|
113 |
|
|
114 |
|newStream|
|
|
115 |
|
|
116 |
(OperatingSystem isReadable:filename) ifFalse:[^nil].
|
2
|
117 |
newStream := self new pathName:filename.
|
1
|
118 |
newStream readwrite.
|
|
119 |
newStream openForReadWrite isNil ifTrue:[^nil].
|
42
|
120 |
"
|
|
121 |
this is not a good idea; someone else might be appending ...
|
|
122 |
|
1
|
123 |
newStream readLimit:(newStream size).
|
42
|
124 |
"
|
1
|
125 |
^ newStream
|
|
126 |
!
|
|
127 |
|
|
128 |
oldFileNamed:filename in:aDirectory
|
|
129 |
"return a FileStream for existing file named filename, aString
|
|
130 |
in aDirectory, a FileDirectory.
|
|
131 |
The file is opened for read/write access."
|
|
132 |
|
|
133 |
|newStream|
|
2
|
134 |
newStream := self new pathName:filename in:aDirectory.
|
1
|
135 |
newStream openForReadWrite isNil ifTrue:[^nil].
|
42
|
136 |
"
|
|
137 |
this is not a good idea; someone else might be appending ...
|
|
138 |
|
1
|
139 |
newStream readLimit:(newStream size).
|
42
|
140 |
"
|
1
|
141 |
^ newStream
|
|
142 |
!
|
|
143 |
|
|
144 |
fileNamed:filename
|
|
145 |
"return a stream on file filename - if the file does not
|
|
146 |
already exist, create it."
|
|
147 |
|
|
148 |
|stream|
|
|
149 |
|
|
150 |
stream := self oldFileNamed:filename.
|
|
151 |
stream isNil ifTrue:[
|
|
152 |
stream := self newFileNamed:filename
|
|
153 |
].
|
|
154 |
^ stream
|
|
155 |
!
|
|
156 |
|
|
157 |
fileNamed:filename in:aDirectory
|
|
158 |
"return a stream on file filename - if the file does not
|
|
159 |
already exist, create it."
|
|
160 |
|
|
161 |
|stream|
|
|
162 |
|
|
163 |
stream := self oldFileNamed:filename in:aDirectory.
|
|
164 |
stream isNil ifTrue:[
|
|
165 |
stream := self newFileNamed:filename in:aDirectory
|
|
166 |
].
|
|
167 |
^ stream
|
|
168 |
!
|
|
169 |
|
|
170 |
readonlyFileNamed:filename
|
|
171 |
"return a readonly FileStream for existing file named filename, aString"
|
|
172 |
|
|
173 |
|newStream|
|
|
174 |
|
|
175 |
(OperatingSystem isReadable:filename) ifFalse:[^nil].
|
|
176 |
|
2
|
177 |
newStream := self new pathName:filename.
|
1
|
178 |
newStream openForReading isNil ifTrue:[^nil].
|
42
|
179 |
"
|
|
180 |
this is not a good idea; someone else might be appending ...
|
|
181 |
|
1
|
182 |
newStream readLimit:(newStream size).
|
42
|
183 |
"
|
1
|
184 |
^ newStream
|
|
185 |
!
|
|
186 |
|
|
187 |
readonlyFileNamed:filename in:aDirectory
|
|
188 |
"return a readonly FileStream for existing file named filename, aString
|
|
189 |
in aDirectory, a FileDirectory"
|
|
190 |
|
|
191 |
|newStream|
|
2
|
192 |
newStream := self new pathName:filename in:aDirectory.
|
1
|
193 |
newStream openForReading isNil ifTrue:[^nil].
|
42
|
194 |
"
|
|
195 |
this is not a good idea; someone else might be appending ...
|
|
196 |
|
1
|
197 |
newStream readLimit:(newStream size).
|
42
|
198 |
"
|
1
|
199 |
^ newStream
|
|
200 |
!
|
|
201 |
|
|
202 |
appendingOldFileNamed:filename
|
|
203 |
"return a FileStream for existing file named filename, aString"
|
|
204 |
|
|
205 |
|newStream|
|
2
|
206 |
newStream := self new pathName:filename.
|
1
|
207 |
newStream openForAppending isNil ifTrue:[^nil].
|
42
|
208 |
"
|
|
209 |
this is not a good idea; I might like to read the written stuff ...
|
|
210 |
|
1
|
211 |
newStream readLimit:(newStream size).
|
42
|
212 |
"
|
1
|
213 |
^ newStream
|
|
214 |
!
|
|
215 |
|
|
216 |
appendingOldFileNamed:filename in:aDirectory
|
|
217 |
"return a FileStream for existing file named filename, aString
|
|
218 |
in aDirectory, a FileDirectory"
|
|
219 |
|
|
220 |
|newStream|
|
2
|
221 |
newStream := self new pathName:filename in:aDirectory.
|
1
|
222 |
newStream openForAppending isNil ifTrue:[^nil].
|
42
|
223 |
"
|
|
224 |
this is not a good idea; I might like to read the written stuff ...
|
|
225 |
|
1
|
226 |
newStream readLimit:(newStream size).
|
42
|
227 |
"
|
1
|
228 |
^ newStream
|
|
229 |
! !
|
|
230 |
|
|
231 |
!FileStream methodsFor:'accessing'!
|
|
232 |
|
|
233 |
store:something
|
|
234 |
"what really should this do"
|
|
235 |
|
31
|
236 |
self nextPutAll:something storeString
|
1
|
237 |
!
|
|
238 |
|
|
239 |
directoryName
|
|
240 |
"return the name of the directory I'm in"
|
|
241 |
|
|
242 |
|path lastIndex index|
|
|
243 |
|
|
244 |
path := pathName.
|
|
245 |
lastIndex := 0.
|
|
246 |
index := path indexOf:$/.
|
|
247 |
[index ~~ 0] whileTrue:[
|
|
248 |
lastIndex := index.
|
|
249 |
index := path indexOf:$/ startingAt:(index + 1)
|
|
250 |
].
|
|
251 |
(lastIndex == 0) ifTrue:[^ '.'].
|
|
252 |
(lastIndex == 1) ifTrue:[^ '/'].
|
31
|
253 |
^ path copyTo:(lastIndex - 1)
|
1
|
254 |
!
|
|
255 |
|
|
256 |
name
|
|
257 |
"return my name without leading direcory-path"
|
|
258 |
|
|
259 |
|lastIndex index|
|
|
260 |
|
|
261 |
lastIndex := 1.
|
|
262 |
[true] whileTrue:[
|
|
263 |
index := pathName indexOf:$/ startingAt:lastIndex.
|
|
264 |
(index == 0) ifTrue:[
|
|
265 |
^ pathName copyFrom:lastIndex
|
|
266 |
].
|
|
267 |
lastIndex := index + 1
|
|
268 |
]
|
|
269 |
!
|
|
270 |
|
|
271 |
pathName
|
|
272 |
"return the pathname"
|
|
273 |
|
|
274 |
^ pathName
|
|
275 |
! !
|
|
276 |
|
|
277 |
!FileStream methodsFor:'private'!
|
|
278 |
|
|
279 |
pathName:filename
|
|
280 |
"set the pathname"
|
|
281 |
|
|
282 |
pathName := filename
|
|
283 |
!
|
|
284 |
|
|
285 |
pathName:filename in:aDirectory
|
|
286 |
"set the pathname starting at aDirectory, a FileDirectory"
|
|
287 |
|
|
288 |
((filename at:1) == $/) ifTrue:[
|
|
289 |
"filename may not start with a '/'"
|
|
290 |
pathName := nil
|
|
291 |
] ifFalse:[
|
|
292 |
pathName := aDirectory pathName.
|
|
293 |
(pathName endsWith:'/') ifFalse:[
|
|
294 |
pathName := pathName , '/'
|
|
295 |
].
|
|
296 |
pathName := pathName , filename
|
|
297 |
]
|
|
298 |
!
|
|
299 |
|
|
300 |
open
|
|
301 |
"open the file"
|
|
302 |
|
|
303 |
pathName isNil ifTrue:[^nil].
|
|
304 |
(mode == #readonly) ifTrue: [
|
77
|
305 |
^ self openWithMode:'r'
|
1
|
306 |
].
|
|
307 |
(mode == #writeonly) ifTrue: [
|
77
|
308 |
^ self openWithMode:'w'
|
1
|
309 |
].
|
77
|
310 |
^ self openWithMode:'r+'
|
1
|
311 |
!
|
|
312 |
|
|
313 |
openWithMode:openmode
|
|
314 |
"open the file; openmode is the string defining the way to open"
|
|
315 |
|
|
316 |
|retVal|
|
|
317 |
%{
|
|
318 |
FILE *f;
|
|
319 |
OBJ path;
|
85
|
320 |
extern OBJ Filename;
|
1
|
321 |
extern errno;
|
|
322 |
|
|
323 |
if (_INST(filePointer) == nil) {
|
|
324 |
path = _INST(pathName);
|
10
|
325 |
if (path != nil
|
13
|
326 |
&& ((_qClass(path)==String) || (_qClass(path) == Filename))) {
|
|
327 |
do {
|
|
328 |
#ifdef LINUX
|
|
329 |
/* LINUX returns a non-NULL f even when interrupted */
|
|
330 |
errno = 0;
|
49
|
331 |
f = (FILE *) fopen((char *) _stringVal(path), (char *) _stringVal(openmode));
|
13
|
332 |
if (errno == EINTR)
|
|
333 |
f = NULL;
|
|
334 |
#else
|
|
335 |
|
49
|
336 |
f = (FILE *) fopen((char *) _stringVal(path), (char *) _stringVal(openmode));
|
13
|
337 |
#endif
|
|
338 |
} while ((f == NULL) && (errno == EINTR));
|
1
|
339 |
if (f == NULL) {
|
85
|
340 |
ExternalStream_LastErrorNumber = _MKSMALLINT(errno);
|
1
|
341 |
_INST(position) = nil;
|
|
342 |
} else {
|
42
|
343 |
_INST(filePointer) = MKOBJ((int)f);
|
1
|
344 |
_INST(position) = _MKSMALLINT(1);
|
|
345 |
retVal = self;
|
|
346 |
}
|
|
347 |
}
|
|
348 |
}
|
|
349 |
%}
|
|
350 |
.
|
|
351 |
retVal notNil ifTrue:[
|
13
|
352 |
buffered := true. "default is buffered"
|
31
|
353 |
Lobby register:self
|
1
|
354 |
].
|
|
355 |
^ retVal
|
|
356 |
!
|
|
357 |
|
|
358 |
openForReading
|
77
|
359 |
"open the file for readonly.
|
|
360 |
If the file does not exist its an error, return nil;
|
|
361 |
otherwise return the receiver."
|
1
|
362 |
|
|
363 |
mode := #readonly.
|
|
364 |
^ self openWithMode:'r'
|
|
365 |
!
|
|
366 |
|
|
367 |
openForWriting
|
77
|
368 |
"open the file writeonly.
|
|
369 |
If the file does not exist its an error, return nil;
|
|
370 |
otherwise return the receiver."
|
1
|
371 |
|
|
372 |
mode := #writeonly.
|
77
|
373 |
^ self openWithMode:'r+' "unix-io does not allow this; open for update here"
|
1
|
374 |
!
|
|
375 |
|
|
376 |
openForAppending
|
77
|
377 |
"open the file for writeonly appending to the end.
|
|
378 |
If the file does not exist its an error, return nil;
|
|
379 |
otherwise return the receiver."
|
1
|
380 |
|
|
381 |
mode := #writeonly.
|
|
382 |
^ self openWithMode:'a+'
|
|
383 |
!
|
|
384 |
|
77
|
385 |
openForReadWrite
|
|
386 |
"open the file for read/write.
|
|
387 |
If the file does not exist its an error, return nil;
|
|
388 |
otherwise return the receiver."
|
|
389 |
|
|
390 |
mode := #readwrite.
|
|
391 |
^ self openWithMode:'r+'
|
|
392 |
!
|
|
393 |
|
1
|
394 |
createForWriting
|
77
|
395 |
"create/truncate the file for writeonly.
|
|
396 |
If the file existed, its truncated; otherwise its created."
|
1
|
397 |
|
|
398 |
mode := #writeonly.
|
77
|
399 |
^ self openWithMode:'w'
|
1
|
400 |
!
|
|
401 |
|
|
402 |
createForReadWrite
|
77
|
403 |
"create/truncate the file for read/write.
|
|
404 |
If the file existed, its truncated; otherwise its created."
|
|
405 |
|
1
|
406 |
|
|
407 |
mode := #readwrite.
|
77
|
408 |
^ self openWithMode:'w+'
|
1
|
409 |
!
|
|
410 |
|
|
411 |
reOpen
|
|
412 |
"sent after snapin to reopen streams"
|
|
413 |
|
|
414 |
filePointer notNil ifTrue:[
|
|
415 |
"it was open, when snapped-out"
|
|
416 |
filePointer := nil.
|
31
|
417 |
Lobby unregister:self.
|
1
|
418 |
self open.
|
|
419 |
filePointer isNil ifTrue:[
|
13
|
420 |
"this happens, if after a restart, the file is no longer accessable ..."
|
|
421 |
|
68
|
422 |
('could not reopen file: ', pathName) errorPrintNewline.
|
1
|
423 |
] ifFalse:[
|
2
|
424 |
self position:position.
|
1
|
425 |
]
|
|
426 |
]
|
31
|
427 |
! !
|
|
428 |
|
|
429 |
!FileStream methodsFor:'queries'!
|
1
|
430 |
|
|
431 |
size
|
|
432 |
"return the size in bytes of the file"
|
|
433 |
|
|
434 |
%{ /* NOCONTEXT */
|
|
435 |
|
|
436 |
#ifdef transputer
|
|
437 |
FILE *f;
|
|
438 |
int size;
|
|
439 |
|
|
440 |
if (_INST(filePointer) != nil) {
|
42
|
441 |
f = (FILE *)MKFD(_INST(filePointer));
|
1
|
442 |
if ((size = filesize(fileno(f))) >= 0) {
|
|
443 |
RETURN ( _MKSMALLINT(size) );
|
|
444 |
}
|
|
445 |
}
|
|
446 |
#else
|
|
447 |
FILE *f;
|
|
448 |
struct stat buf;
|
10
|
449 |
int ret;
|
|
450 |
extern errno;
|
42
|
451 |
int fd;
|
1
|
452 |
|
|
453 |
if (_INST(filePointer) != nil) {
|
42
|
454 |
f = (FILE *)MKFD(_INST(filePointer));
|
|
455 |
fd = fileno(f);
|
13
|
456 |
do {
|
42
|
457 |
ret = fstat(fd, &buf);
|
13
|
458 |
} while ((ret < 0) && (errno == EINTR));
|
10
|
459 |
if (ret >= 0) {
|
1
|
460 |
RETURN ( _MKSMALLINT(buf.st_size) );
|
|
461 |
}
|
85
|
462 |
ExternalStream_LastErrorNumber = _MKSMALLINT(errno);
|
1
|
463 |
}
|
|
464 |
#endif
|
|
465 |
%}
|
|
466 |
.
|
|
467 |
"could add a fall-back here:
|
|
468 |
|
|
469 |
oldPosition := self position.
|
|
470 |
self setToEnd.
|
|
471 |
sz := self position.
|
|
472 |
self position:oldPosition.
|
|
473 |
^ sz
|
|
474 |
"
|
|
475 |
filePointer isNil ifTrue:[^ self errorNotOpen].
|
|
476 |
^ self primitiveFailed
|
|
477 |
!
|
|
478 |
|
|
479 |
position
|
|
480 |
"return the read/write position in the file -
|
31
|
481 |
notice, in smalltalk indices start at 1 so begin of file is 1"
|
1
|
482 |
|
|
483 |
%{ /* NOCONTEXT */
|
|
484 |
|
|
485 |
FILE *f;
|
|
486 |
long currentPosition;
|
10
|
487 |
extern errno;
|
1
|
488 |
|
|
489 |
if (_INST(filePointer) != nil) {
|
42
|
490 |
f = (FILE *)MKFD(_INST(filePointer));
|
13
|
491 |
do {
|
|
492 |
if (_INST(buffered) == true) {
|
42
|
493 |
currentPosition = (long) ftell(f);
|
13
|
494 |
} else {
|
42
|
495 |
currentPosition = (long) lseek(fileno(f), 0L, SEEK_CUR);
|
13
|
496 |
}
|
|
497 |
} while ((currentPosition < 0) && (errno == EINTR));
|
1
|
498 |
if (currentPosition >= 0) {
|
|
499 |
/*
|
|
500 |
* notice: Smalltalk index starts at 1
|
|
501 |
*/
|
|
502 |
RETURN ( _MKSMALLINT(currentPosition + 1) );
|
|
503 |
}
|
85
|
504 |
ExternalStream_LastErrorNumber = _MKSMALLINT(errno);
|
1
|
505 |
}
|
|
506 |
%}
|
|
507 |
.
|
|
508 |
filePointer isNil ifTrue:[^ self errorNotOpen].
|
|
509 |
^ self primitiveFailed
|
|
510 |
!
|
|
511 |
|
|
512 |
position:newPos
|
|
513 |
"set the read/write position in the file"
|
|
514 |
|
|
515 |
%{ /* NOCONTEXT */
|
|
516 |
|
|
517 |
FILE *f;
|
10
|
518 |
int ret;
|
1
|
519 |
extern errno;
|
|
520 |
|
|
521 |
if (_INST(filePointer) != nil) {
|
|
522 |
if (_isSmallInteger(newPos)) {
|
42
|
523 |
f = (FILE *)MKFD(_INST(filePointer));
|
1
|
524 |
/*
|
|
525 |
* notice: Smalltalk index starts at 1
|
|
526 |
*/
|
13
|
527 |
do {
|
|
528 |
if (_INST(buffered) == true) {
|
42
|
529 |
ret = fseek(f, (long) (_intVal(newPos) - 1), SEEK_SET);
|
10
|
530 |
} else {
|
42
|
531 |
ret = (long) lseek(fileno(f), (long)(_intVal(newPos) - 1), SEEK_SET);
|
13
|
532 |
}
|
|
533 |
} while ((ret < 0) && (errno == EINTR));
|
10
|
534 |
if (ret >= 0) {
|
1
|
535 |
_INST(position) = newPos;
|
77
|
536 |
/*
|
|
537 |
* just to make certain ...
|
|
538 |
*/
|
|
539 |
_INST(hitEOF) = false;
|
1
|
540 |
RETURN ( self );
|
|
541 |
}
|
85
|
542 |
ExternalStream_LastErrorNumber = _MKSMALLINT(errno);
|
1
|
543 |
}
|
|
544 |
}
|
|
545 |
%}
|
|
546 |
.
|
|
547 |
filePointer isNil ifTrue:[^ self errorNotOpen].
|
|
548 |
^ self primitiveFailed
|
|
549 |
!
|
|
550 |
|
|
551 |
setToEnd
|
|
552 |
"set the read/write position in the file to be at the end of the file"
|
|
553 |
|
|
554 |
%{
|
|
555 |
FILE *f;
|
10
|
556 |
int ret;
|
1
|
557 |
extern errno;
|
|
558 |
|
49
|
559 |
if (_INST(filePointer) != nil) {
|
|
560 |
f = (FILE *)MKFD(_INST(filePointer));
|
|
561 |
_INST(position) = nil;
|
|
562 |
do {
|
|
563 |
if (_INST(buffered) == true) {
|
|
564 |
ret = fseek(f, 0L, SEEK_END);
|
|
565 |
} else {
|
|
566 |
ret = (long)lseek(fileno(f), 0L, SEEK_END);
|
|
567 |
}
|
|
568 |
} while ((ret < 0) && (errno == EINTR));
|
|
569 |
if (ret >= 0) {
|
|
570 |
RETURN ( self );
|
10
|
571 |
}
|
85
|
572 |
ExternalStream_LastErrorNumber = _MKSMALLINT(errno);
|
1
|
573 |
}
|
|
574 |
%}
|
|
575 |
.
|
49
|
576 |
filePointer isNil ifTrue:[^ self errorNotOpen].
|
|
577 |
DemoMode ifTrue:[^ self warn:'no save in Demo mode'].
|
1
|
578 |
^ self primitiveFailed
|
|
579 |
! !
|
|
580 |
|
2
|
581 |
!FileStream methodsFor:'testing'!
|
|
582 |
|
|
583 |
isFileStream
|
|
584 |
"return true, if the receiver is some kind of fileStream.
|
|
585 |
redefined from Object"
|
|
586 |
|
|
587 |
^ true
|
|
588 |
! !
|
|
589 |
|
1
|
590 |
!FileStream methodsFor:'printing & storing'!
|
|
591 |
|
|
592 |
printOn:aStream
|
|
593 |
aStream nextPutAll:'(a FileStream for:'.
|
|
594 |
aStream nextPutAll:pathName.
|
|
595 |
aStream nextPut:$)
|
|
596 |
!
|
|
597 |
|
|
598 |
storeOn:aStream
|
|
599 |
aStream nextPutAll:'(FileStream oldFileNamed:'.
|
|
600 |
aStream nextPutAll:pathName.
|
|
601 |
(self position ~~ 1) ifTrue:[
|
|
602 |
aStream nextPutAll:'; position:'.
|
|
603 |
self position storeOn:aStream
|
|
604 |
].
|
|
605 |
aStream nextPut:$)
|
|
606 |
! !
|