48 "return a FileStream for new file named filename, aString. |
48 "return a FileStream for new file named filename, aString. |
49 If the file exists, it is truncated, otherwise created. |
49 If the file exists, it is truncated, otherwise created. |
50 The file is opened for write access only." |
50 The file is opened for write access only." |
51 |
51 |
52 |newStream| |
52 |newStream| |
53 newStream := (self basicNew) pathName:filename. |
53 newStream := self new pathName:filename. |
54 newStream createForWriting isNil ifTrue:[^nil]. |
54 newStream createForWriting isNil ifTrue:[^nil]. |
55 ^ newStream |
55 ^ newStream |
56 ! |
56 ! |
57 |
57 |
58 newFileNamed:filename in:aDirectory |
58 newFileNamed:filename in:aDirectory |
60 in aDirectory, a FileDirectory. |
60 in aDirectory, a FileDirectory. |
61 If the file exists, it is truncated, otherwise created. |
61 If the file exists, it is truncated, otherwise created. |
62 The file is opened for write access only." |
62 The file is opened for write access only." |
63 |
63 |
64 |newStream| |
64 |newStream| |
65 newStream := (self basicNew) pathName:filename in:aDirectory. |
65 newStream := self new pathName:filename in:aDirectory. |
66 newStream createForWriting isNil ifTrue:[^nil]. |
66 newStream createForWriting isNil ifTrue:[^nil]. |
67 ^ newStream |
67 ^ newStream |
68 ! |
68 ! |
69 |
69 |
70 oldFileNamed:filename |
70 oldFileNamed:filename |
85 "return a FileStream for existing file named filename, aString |
85 "return a FileStream for existing file named filename, aString |
86 in aDirectory, a FileDirectory. |
86 in aDirectory, a FileDirectory. |
87 The file is opened for read/write access." |
87 The file is opened for read/write access." |
88 |
88 |
89 |newStream| |
89 |newStream| |
90 newStream := (self basicNew) pathName:filename in:aDirectory. |
90 newStream := self new pathName:filename in:aDirectory. |
91 newStream openForReadWrite isNil ifTrue:[^nil]. |
91 newStream openForReadWrite isNil ifTrue:[^nil]. |
92 newStream readLimit:(newStream size). |
92 newStream readLimit:(newStream size). |
93 ^ newStream |
93 ^ newStream |
94 ! |
94 ! |
95 |
95 |
124 |
124 |
125 |newStream| |
125 |newStream| |
126 |
126 |
127 (OperatingSystem isReadable:filename) ifFalse:[^nil]. |
127 (OperatingSystem isReadable:filename) ifFalse:[^nil]. |
128 |
128 |
129 newStream := (self basicNew) pathName:filename. |
129 newStream := self new pathName:filename. |
130 newStream openForReading isNil ifTrue:[^nil]. |
130 newStream openForReading isNil ifTrue:[^nil]. |
131 newStream readLimit:(newStream size). |
131 newStream readLimit:(newStream size). |
132 ^ newStream |
132 ^ newStream |
133 ! |
133 ! |
134 |
134 |
135 readonlyFileNamed:filename in:aDirectory |
135 readonlyFileNamed:filename in:aDirectory |
136 "return a readonly FileStream for existing file named filename, aString |
136 "return a readonly FileStream for existing file named filename, aString |
137 in aDirectory, a FileDirectory" |
137 in aDirectory, a FileDirectory" |
138 |
138 |
139 |newStream| |
139 |newStream| |
140 newStream := (self basicNew) pathName:filename in:aDirectory. |
140 newStream := self new pathName:filename in:aDirectory. |
141 newStream openForReading isNil ifTrue:[^nil]. |
141 newStream openForReading isNil ifTrue:[^nil]. |
142 newStream readLimit:(newStream size). |
142 newStream readLimit:(newStream size). |
143 ^ newStream |
143 ^ newStream |
144 ! |
144 ! |
145 |
145 |
146 appendingOldFileNamed:filename |
146 appendingOldFileNamed:filename |
147 "return a FileStream for existing file named filename, aString" |
147 "return a FileStream for existing file named filename, aString" |
148 |
148 |
149 |newStream| |
149 |newStream| |
150 newStream := (self basicNew) pathName:filename. |
150 newStream := self new pathName:filename. |
151 newStream openForAppending isNil ifTrue:[^nil]. |
151 newStream openForAppending isNil ifTrue:[^nil]. |
152 newStream readLimit:(newStream size). |
152 newStream readLimit:(newStream size). |
153 ^ newStream |
153 ^ newStream |
154 ! |
154 ! |
155 |
155 |
156 appendingOldFileNamed:filename in:aDirectory |
156 appendingOldFileNamed:filename in:aDirectory |
157 "return a FileStream for existing file named filename, aString |
157 "return a FileStream for existing file named filename, aString |
158 in aDirectory, a FileDirectory" |
158 in aDirectory, a FileDirectory" |
159 |
159 |
160 |newStream| |
160 |newStream| |
161 newStream := (self basicNew) pathName:filename in:aDirectory. |
161 newStream := self new pathName:filename in:aDirectory. |
162 newStream openForAppending isNil ifTrue:[^nil]. |
162 newStream openForAppending isNil ifTrue:[^nil]. |
163 newStream readLimit:(newStream size). |
163 newStream readLimit:(newStream size). |
164 ^ newStream |
164 ^ newStream |
165 ! ! |
165 ! ! |
166 |
166 |
167 !FileStream methodsFor:'accessing'! |
167 !FileStream methodsFor:'accessing'! |
168 |
168 |
169 store:something |
169 store:something |
170 "what really should this do" |
170 "what really should this do" |
171 |
171 |
172 self nextPutAll:something |
172 self nextPutAll:something printString |
173 ! |
173 ! |
174 |
174 |
175 directoryName |
175 directoryName |
176 "return the name of the directory I'm in" |
176 "return the name of the directory I'm in" |
177 |
177 |
326 filePointer notNil ifTrue:[ |
326 filePointer notNil ifTrue:[ |
327 "it was open, when snapped-out" |
327 "it was open, when snapped-out" |
328 filePointer := nil. |
328 filePointer := nil. |
329 self open. |
329 self open. |
330 filePointer isNil ifTrue:[ |
330 filePointer isNil ifTrue:[ |
331 Transcript showCr:('could not reopen file: ', pathName) |
331 Transcript showCr:('could not reopen file: ', pathName). |
|
332 lobby unregister:self |
332 ] ifFalse:[ |
333 ] ifFalse:[ |
333 self position:position |
334 self position:position. |
|
335 lobby changed:self |
334 ] |
336 ] |
335 ] |
337 ] |
336 ! |
338 ! |
337 |
339 |
338 size |
340 size |