author | Claus Gittinger <cg@exept.de> |
Thu, 23 Nov 1995 11:46:35 +0100 | |
changeset 620 | c7353f86a302 |
parent 615 | e9d0e782206d |
child 630 | b785d23d7c5b |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 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 |
Object subclass:#Filename |
|
159 | 14 |
instanceVariableNames:'nameString' |
276 | 15 |
classVariableNames:'NextTempFilenameIndex' |
159 | 16 |
poolDictionaries:'' |
615 | 17 |
category:'System-Support' |
18 |
! |
|
1 | 19 |
|
88 | 20 |
!Filename class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
159 | 25 |
All Rights Reserved |
1 | 26 |
|
88 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
Filenames; originally added for ST-80 compatibility, is |
|
39 |
taking over functionality from other classes (FileDirectory). |
|
92 | 40 |
|
41 |
Instances of Filename do not nescessarily represent valid or existing |
|
42 |
files - i.e. it is possible (and useful) to have instances for non-existing |
|
43 |
files around. In other words: the name-string is not checked automatically |
|
44 |
for being correct or existing. |
|
45 |
Thus, it is possible to do queries such as: |
|
46 |
||
159 | 47 |
'/fee/foo/foe' asFilename exists |
48 |
'/not_existing' asFilename isDirectory |
|
49 |
'/foo/bar' asFilename isReadable |
|
92 | 50 |
|
195 | 51 |
(all of the above examples will probably return false on your machine ;-). |
276 | 52 |
|
53 |
examples: |
|
54 |
||
55 |
'Makefile' asFilename readStream |
|
56 |
||
57 |
'newFile' asFilename writeStream |
|
58 |
||
59 |
Filename newTemporary writeStream |
|
88 | 60 |
" |
360 | 61 |
! |
62 |
||
63 |
examples |
|
64 |
" |
|
65 |
does a file/directory exist ?: |
|
66 |
||
67 |
|f| |
|
68 |
||
69 |
f := 'foobar' asFilename. |
|
70 |
^ f exists |
|
71 |
||
72 |
||
73 |
is it a directory ?: |
|
74 |
||
75 |
|f| |
|
76 |
||
77 |
f := '/tmp' asFilename. |
|
78 |
^ f isDirectory. |
|
79 |
||
80 |
||
81 |
get the working directory: |
|
82 |
||
83 |
^ Filename defaultDirectory |
|
84 |
||
85 |
||
86 |
get a files full pathname |
|
87 |
(caring for relative names or symbolic links): |
|
88 |
||
89 |
|f| |
|
90 |
||
91 |
f := '..' asFilename. |
|
92 |
^ f pathName |
|
93 |
||
94 |
||
95 |
get a directories directory: |
|
96 |
||
97 |
|f| |
|
98 |
||
99 |
f := Filename defaultDirectory. |
|
100 |
^ f directory |
|
101 |
||
102 |
||
103 |
get a files directory: |
|
104 |
||
105 |
|f| |
|
106 |
||
107 |
f := './smalltalk' asFilename. |
|
108 |
^ f directory |
|
109 |
||
110 |
||
111 |
getting access & modification times: |
|
112 |
||
113 |
||
114 |
|f| |
|
115 |
||
116 |
f := '/tmp' asFilename. |
|
117 |
^ f dates |
|
118 |
||
119 |
access time only: |
|
120 |
||
121 |
|f| |
|
122 |
||
123 |
f := '/tmp' asFilename. |
|
124 |
^ f dates at:#accessed |
|
125 |
||
126 |
||
127 |
getting all information on a file/directory: |
|
128 |
||
129 |
||
130 |
|f| |
|
131 |
||
132 |
f := '/tmp' asFilename. |
|
133 |
^ f info |
|
134 |
||
135 |
||
136 |
getting a temporary file (unique name): |
|
137 |
||
138 |
|f| |
|
139 |
||
140 |
f := Filename newTemporary. |
|
141 |
^ f |
|
142 |
||
143 |
||
144 |
creating, writing, reading and removing a temporary file: |
|
145 |
||
146 |
||
147 |
|f writeStream readStream| |
|
148 |
||
149 |
f := Filename newTemporary. |
|
150 |
writeStream := f writeStream. |
|
151 |
writeStream nextPutAll:'hello world'. |
|
152 |
writeStream cr. |
|
153 |
writeStream close. |
|
154 |
||
155 |
'contents (as seen by unix''s cat command:' printNL. |
|
156 |
OperatingSystem executeCommand:('cat ' , f pathName). |
|
157 |
||
158 |
readStream := f readStream. |
|
159 |
Transcript showCr:'contents as seen by smalltalk:'. |
|
160 |
Transcript showCr:(readStream upToEnd). |
|
161 |
readStream close. |
|
162 |
||
163 |
f delete. |
|
164 |
||
165 |
||
166 |
getting a directories contents: |
|
167 |
||
168 |
|f files| |
|
169 |
||
170 |
f := '.' asFilename. |
|
171 |
files := f directoryContents. |
|
172 |
Transcript showCr:'the files are:'. |
|
173 |
Transcript showCr:(files printString). |
|
174 |
||
175 |
||
176 |
editing a file: |
|
177 |
||
178 |
|f| |
|
179 |
||
180 |
f := '/tmp/fooBar' asFilename. |
|
181 |
(f writeStream) nextPutAll:'hello world'; close. |
|
182 |
||
183 |
f edit |
|
184 |
" |
|
615 | 185 |
! |
186 |
||
187 |
version |
|
188 |
^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.42 1995-11-23 02:00:32 cg Exp $' |
|
88 | 189 |
! ! |
1 | 190 |
|
191 |
!Filename class methodsFor:'instance creation'! |
|
192 |
||
276 | 193 |
currentDirectory |
194 |
"return a filename for the current directory" |
|
195 |
||
196 |
^ self named:(FileDirectory currentDirectory pathName) |
|
197 |
||
198 |
" |
|
199 |
Filename currentDirectory |
|
200 |
" |
|
201 |
! |
|
202 |
||
328 | 203 |
defaultDirectory |
204 |
"ST80 compatibility: same as currentDirectory" |
|
205 |
||
206 |
^ self currentDirectory |
|
207 |
||
208 |
" |
|
209 |
Filename defaultDirectory |
|
210 |
" |
|
211 |
! |
|
212 |
||
542 | 213 |
defaultDirectoryName |
214 |
"ST80 compatibility: return the defaultDirectories name (as a string)" |
|
215 |
||
216 |
^ self defaultDirectory name |
|
217 |
||
218 |
" |
|
219 |
Filename defaultDirectoryName |
|
220 |
" |
|
221 |
! |
|
222 |
||
615 | 223 |
fromUser |
224 |
"show a box to enter a filename. Return a filename instance or |
|
225 |
nil (if cancel was pressed)." |
|
226 |
||
227 |
|name| |
|
228 |
||
229 |
name := FileSelectionBox requestFilename. |
|
230 |
name notNil ifTrue:[^ self named:name]. |
|
231 |
^ nil |
|
232 |
||
233 |
" |
|
234 |
Filename fromUser |
|
235 |
" |
|
236 |
! |
|
237 |
||
238 |
named:aString |
|
239 |
"return a filename for a directory named aString. |
|
240 |
This is the same as 'aString asFilename'." |
|
241 |
||
242 |
^ (self basicNew) setName:aString |
|
243 |
||
244 |
" |
|
245 |
Filename named:'/tmp/fooBar' |
|
246 |
" |
|
247 |
! |
|
248 |
||
276 | 249 |
newTemporary |
325 | 250 |
"return a new unique filename - use this for temporary files. |
251 |
The filenames returned are '/tmp/stxtmp_xx_nn' where xx is our |
|
252 |
unix process id, and nn is a unique number, incremented with every |
|
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
253 |
call to this method. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
254 |
If any of the environment variables ST_TMPDIR or TMPDIR is set, |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
255 |
its value defines the temp directory." |
276 | 256 |
|
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
257 |
|tempDir| |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
258 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
259 |
tempDir := OperatingSystem getEnvironment:'ST_TMPDIR'. |
422 | 260 |
tempDir isNil ifTrue:[ |
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
261 |
tempDir := OperatingSystem getEnvironment:'TMPDIR'. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
262 |
tempDir isNil ifTrue:[ |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
263 |
tempDir := '/tmp' |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
264 |
]. |
422 | 265 |
]. |
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
266 |
^ self newTemporaryIn:tempDir |
276 | 267 |
|
268 |
" |
|
422 | 269 |
Filename newTemporary |
270 |
Filename newTemporary |
|
276 | 271 |
" |
422 | 272 |
|
273 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
274 |
"Modified: 4.11.1995 / 20:08:51 / cg" |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
275 |
! |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
276 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
277 |
newTemporaryIn:aDirectoryPrefix |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
278 |
"return a new unique filename - use this for temporary files. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
279 |
The filenames returned are in aDirectoryPrefix and named 'stxtmp_xx_nn', |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
280 |
where xx is our unix process id, and nn is a unique number, incremented |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
281 |
with every call to this method. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
282 |
Notice: only a filename object is created and returned - no physical |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
283 |
file is created by this method (i.e. you have to send #writeStream or |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
284 |
whatever to it in order to really create something). |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
285 |
See also: #newTemporary which looks for a good temp directory." |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
286 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
287 |
|pid nm| |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
288 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
289 |
NextTempFilenameIndex isNil ifTrue:[ |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
290 |
NextTempFilenameIndex := 1. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
291 |
]. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
292 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
293 |
" |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
294 |
the following has to be made OS independent ... |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
295 |
" |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
296 |
pid := OperatingSystem getProcessId printString. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
297 |
nm := 'stxtmp_' , pid , '_' , NextTempFilenameIndex printString. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
298 |
NextTempFilenameIndex := NextTempFilenameIndex + 1. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
299 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
300 |
(aDirectoryPrefix isNil or:[aDirectoryPrefix asString isEmpty]) ifFalse:[ |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
301 |
nm := aDirectoryPrefix asFilename construct:nm |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
302 |
] ifTrue:[ |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
303 |
nm := nm asFilename |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
304 |
]. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
305 |
^ nm |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
306 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
307 |
"temp files in '/tmp': |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
308 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
309 |
Filename newTemporary |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
310 |
Filename newTemporaryIn:'/tmp' |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
311 |
Filename newTemporaryIn:'/tmp' |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
312 |
" |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
313 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
314 |
"temp files somewhere (not recommended): |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
315 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
316 |
Filename newTemporaryIn:'/usr/tmp' |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
317 |
Filename newTemporaryIn:'/' |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
318 |
" |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
319 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
320 |
"a local temp file: |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
321 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
322 |
Filename newTemporaryIn:'' |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
323 |
Filename newTemporaryIn:nil |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
324 |
Filename newTemporaryIn:'.' |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
325 |
Filename newTemporaryIn:('source' asFilename) |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
326 |
" |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
327 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
328 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
329 |
"Modified: 4.11.1995 / 20:26:23 / cg" |
1 | 330 |
! ! |
331 |
||
2 | 332 |
!Filename class methodsFor:'queries'! |
333 |
||
326 | 334 |
defaultClass |
335 |
"ST-80 compatibility: |
|
422 | 336 |
in ST-80, different subclasses of Filename are used for different |
337 |
OperatingSystems; defaultClass is supposed to return an appropriate class. |
|
326 | 338 |
Since in ST/X, there is (currently) only one Filename class, return it here." |
339 |
||
340 |
^ self |
|
328 | 341 |
! |
342 |
||
440 | 343 |
filenameCompletionFor:aString directory:inDirectory directoriesOnly:directoriesOnly filesOnly:filesOnly ifMultiple:aBlock |
344 |
"perform filename completion on aString in some directory; |
|
345 |
return the longest matching filename prefix as a string. |
|
346 |
If directoriesOnly and filesOnly are true, only directories and files |
|
347 |
are considered respectively. If multiple files match, the exception |
|
348 |
block aBlock is evaluated with a filename representing the directory |
|
349 |
(where the match was done) as argument. |
|
350 |
(this may be different from the inDirectory argument, if aString is absolute |
|
351 |
or starts with ../)" |
|
352 |
||
353 |
|s f matchSet nMatch name words dir| |
|
354 |
||
355 |
s := aString. |
|
356 |
" |
|
357 |
find the last word ... |
|
358 |
" |
|
359 |
words := s asCollectionOfWords. |
|
360 |
words size == 0 ifTrue:[ |
|
473
f92507d781d2
filenameCompletion: bad return value when called with empty string
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
361 |
aBlock value:'.' asFilename. |
f92507d781d2
filenameCompletion: bad return value when called with empty string
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
362 |
^ '' |
440 | 363 |
]. |
364 |
||
365 |
f := words last asFilename. |
|
366 |
||
367 |
matchSet := f filenameCompletionIn:inDirectory. |
|
368 |
||
369 |
dir := f directory. |
|
370 |
||
371 |
directoriesOnly ifTrue:[ |
|
372 |
matchSet := matchSet select:[:aFilename | |
|
373 |
(dir construct:aFilename) isDirectory |
|
374 |
]. |
|
375 |
] ifFalse:[ |
|
376 |
filesOnly ifTrue:[ |
|
377 |
matchSet := matchSet select:[:aFilename | |
|
378 |
(dir construct:aFilename) isDirectory not |
|
379 |
]. |
|
380 |
] |
|
381 |
]. |
|
382 |
||
383 |
(nMatch := matchSet size) ~~ 1 ifTrue:[ |
|
384 |
" |
|
385 |
more than one possible completion - |
|
386 |
" |
|
387 |
aBlock value:f |
|
388 |
]. |
|
389 |
" |
|
390 |
even with more than one possible completion, |
|
391 |
f's name is now the common prefix |
|
392 |
" |
|
393 |
name := f asString. |
|
394 |
nMatch == 1 ifTrue:[ |
|
395 |
" |
|
396 |
exactly one possible completion - |
|
397 |
" |
|
398 |
f := dir construct:matchSet first. |
|
399 |
||
400 |
directoriesOnly ifFalse:[ |
|
401 |
f isDirectory ifTrue:[ |
|
402 |
(name endsWith:(Filename separator)) ifFalse:[ |
|
403 |
name := name , '/' |
|
404 |
]. |
|
405 |
]. |
|
406 |
] |
|
407 |
]. |
|
408 |
||
409 |
" |
|
410 |
construct new contents, by taking |
|
411 |
last words completion |
|
412 |
" |
|
413 |
s := ''. |
|
414 |
1 to:(words size - 1) do:[:idx | |
|
415 |
s := s , (words at:idx) , ' ' |
|
416 |
]. |
|
417 |
s := s , name. |
|
418 |
||
419 |
"/ special: if there was no change, and the string represented |
|
420 |
"/ is a directories name, add a directory separator |
|
421 |
s = aString ifTrue:[ |
|
422 |
(s endsWith:Filename separator) ifFalse:[ |
|
423 |
s asFilename isDirectory ifTrue:[ |
|
424 |
^ s , Filename separator asString |
|
425 |
] |
|
426 |
] |
|
427 |
]. |
|
428 |
||
429 |
^ s |
|
615 | 430 |
! |
431 |
||
432 |
isCaseSensitive |
|
433 |
"return true, if filenames are case sensitive. |
|
434 |
We ask the OS about this, to be independent here." |
|
435 |
||
436 |
^ OperatingSystem caseSensitiveFilenames |
|
437 |
! |
|
438 |
||
439 |
localNameStringFrom:aString |
|
440 |
"ST-80 compatibility. |
|
441 |
what does this do ? (used in FileNavigator-goody). |
|
442 |
GUESS: does it strip off the voulume-character on MSDOS systems ?" |
|
443 |
||
444 |
(aString startsWith:'/') ifTrue:[ |
|
445 |
^ aString copyFrom:2 |
|
446 |
]. |
|
447 |
^ aString |
|
448 |
||
449 |
"Modified: 7.9.1995 / 10:44:56 / claus" |
|
450 |
! |
|
451 |
||
452 |
parentDirectoryName |
|
453 |
"return the name used for the parent directory. |
|
454 |
This is '..' for unix and dos-like systems. |
|
455 |
(there may be more in the future." |
|
456 |
||
457 |
^ OperatingSystem parentDirectoryName |
|
458 |
||
459 |
" |
|
460 |
Filename parentDirectoryName |
|
461 |
" |
|
462 |
! |
|
463 |
||
464 |
separator |
|
465 |
"return the file/directory separator. |
|
466 |
Usually, this is $/ for unix-like systems |
|
467 |
and $\ for dos-like ones (there may be more in the future)." |
|
468 |
||
469 |
^ OperatingSystem fileSeparator |
|
470 |
||
471 |
" |
|
472 |
Filename separator |
|
473 |
" |
|
474 |
! |
|
475 |
||
476 |
suffixSeparator |
|
477 |
"return the filename suffix separator. |
|
478 |
Usually, this is $. for unix-like and msdos systems |
|
479 |
(there is currently no knowns system, where this differs)" |
|
480 |
||
481 |
^ $. |
|
482 |
||
483 |
" |
|
484 |
Filename suffixSeparator |
|
485 |
" |
|
486 |
||
487 |
"Modified: 7.9.1995 / 11:10:43 / claus" |
|
488 |
! |
|
489 |
||
490 |
volumes |
|
491 |
"ST-80 compatibility. |
|
492 |
what does this do ? (used in FileNavigator-goody). |
|
493 |
GUESS: does it return the available drives on MSDOS systems ?" |
|
494 |
||
495 |
^ #('/') |
|
496 |
||
497 |
"Modified: 7.9.1995 / 10:45:25 / claus" |
|
498 |
! ! |
|
499 |
||
500 |
!Filename methodsFor:'comparing'! |
|
501 |
||
502 |
= aFilename |
|
503 |
"return true, if the argument represents the same filename" |
|
504 |
||
505 |
|str| |
|
506 |
||
507 |
self species == aFilename species ifTrue:[ |
|
508 |
str := aFilename asString. |
|
509 |
self class isCaseSensitive ifTrue:[ |
|
510 |
^ nameString = str |
|
511 |
]. |
|
512 |
^ nameString sameAs:str |
|
513 |
]. |
|
514 |
^ false |
|
515 |
! |
|
516 |
||
517 |
hash |
|
518 |
"return an integer useful as a hash-key" |
|
519 |
||
520 |
^ nameString hash |
|
521 |
! ! |
|
522 |
||
523 |
!Filename methodsFor:'converting'! |
|
524 |
||
525 |
asAbsoluteFilename |
|
526 |
"return the receiver converted to a filename with |
|
527 |
an absolute pathname." |
|
528 |
||
529 |
^ self pathName asFilename |
|
530 |
! |
|
531 |
||
532 |
asFilename |
|
533 |
"return the receiver converted to a filename." |
|
534 |
||
535 |
"Thats pretty easy here :-)" |
|
536 |
^ self |
|
537 |
! |
|
538 |
||
539 |
asString |
|
540 |
"return the receiver converted to a string" |
|
541 |
||
542 |
^ nameString |
|
543 |
! |
|
544 |
||
545 |
makeLegalFilename |
|
546 |
"convert the receveivers name to be a legal filename. |
|
547 |
The implementation may change in the future to be more |
|
548 |
OS specific." |
|
549 |
||
550 |
" |
|
551 |
actually, in Unix spaces are allowed - but it makes life |
|
552 |
so hard; therefore, replace them by underscores ... |
|
553 |
" |
|
554 |
nameString replaceAll:(Character space) by:$_. |
|
555 |
" |
|
556 |
need more - especially on SYS5.3 type systems, |
|
557 |
we may want to contract the fileName to 14 characters. |
|
558 |
" |
|
559 |
^ self |
|
560 |
||
561 |
" |
|
562 |
'hello world' asFilename makeLegalFilename |
|
563 |
" |
|
2 | 564 |
! ! |
565 |
||
542 | 566 |
!Filename methodsFor:'error handling'! |
567 |
||
615 | 568 |
accessDeniedError:filename |
569 |
^ OperatingSystem accessDeniedErrorSignal |
|
542 | 570 |
raiseRequestWith:filename |
615 | 571 |
errorString:('access denied: ' , filename asString) |
572 |
! |
|
573 |
||
574 |
fileCreationError:filename |
|
575 |
^ OperatingSystem accessDeniedErrorSignal |
|
576 |
raiseRequestWith:filename |
|
577 |
errorString:('cannot create/write file: ' , filename asString) |
|
542 | 578 |
! |
579 |
||
580 |
fileNotFoundError:filename |
|
581 |
^ OperatingSystem fileNotFoundErrorSignal |
|
582 |
raiseRequestWith:filename |
|
583 |
errorString:('file not found: ' , filename asString) |
|
584 |
! |
|
585 |
||
586 |
removeError:filename |
|
587 |
^ OperatingSystem accessDeniedErrorSignal |
|
588 |
raiseRequestWith:filename |
|
589 |
errorString:('cannot remove: ' , filename asString) |
|
615 | 590 |
! |
591 |
||
592 |
reportError:string with:filename |
|
593 |
^ OperatingSystem errorSignal |
|
594 |
raiseRequestWith:filename |
|
595 |
errorString:string |
|
596 |
! ! |
|
597 |
||
598 |
!Filename methodsFor:'file access'! |
|
599 |
||
600 |
appendingWriteStream |
|
601 |
"return a stream for appending to the file represented by the receiver. |
|
602 |
If the file does not already exist, it is created." |
|
603 |
||
604 |
^ FileStream appendingOldFileNamed:nameString |
|
605 |
! |
|
606 |
||
607 |
newReadWriteStream |
|
608 |
"return a stream for read/write the file represented by the receiver. |
|
609 |
If the file does not already exist, it is created." |
|
610 |
||
611 |
^ FileStream newFileNamed:nameString |
|
612 |
! |
|
613 |
||
614 |
readStream |
|
615 |
"return a stream for reading from the file represented by the receiver. |
|
616 |
If the file does not already exist, nil is returned." |
|
617 |
||
618 |
^ FileStream readonlyFileNamed:nameString |
|
619 |
||
620 |
" |
|
621 |
'/tmp/foo' asFilename readStream |
|
622 |
" |
|
623 |
! |
|
624 |
||
625 |
readWriteStream |
|
626 |
"return a stream for read/write the file represented by the receiver. |
|
627 |
If the file does not already exist, nil is returned." |
|
628 |
||
629 |
^ FileStream oldFileNamed:nameString |
|
630 |
! |
|
631 |
||
632 |
writeStream |
|
633 |
"return a stream for writing to the file represented by the receiver. |
|
634 |
If the file does not already exist, it is created." |
|
635 |
||
636 |
^ FileStream newFileForWritingNamed:nameString |
|
637 |
||
638 |
" |
|
639 |
'/tmp/foo' asFilename writeStream |
|
640 |
" |
|
641 |
! ! |
|
642 |
||
643 |
!Filename methodsFor:'file operations'! |
|
644 |
||
645 |
addAccessRights:aCollection |
|
646 |
"add the access rights as specified in aCollection for the file represented |
|
647 |
by the receiver. The argument must be a collection of symbols, |
|
648 |
such as #readUser, #writeGroup etc." |
|
649 |
||
650 |
|access| |
|
651 |
||
652 |
access := OperatingSystem accessModeOf:nameString. |
|
653 |
aCollection do:[:accessSymbol | |
|
654 |
access := access bitOr:(OperatingSystem accessMaskFor:accessSymbol). |
|
655 |
]. |
|
656 |
(OperatingSystem changeAccessModeOf:nameString to:access) ifFalse:[ |
|
657 |
^ self accessDeniedError:self |
|
658 |
] |
|
659 |
||
660 |
" |
|
661 |
'foo' asFilename writeStream close. |
|
662 |
'foo' asFilename addAccessRights:#(readUser readGroup readOthers). |
|
663 |
'foo' asFilename addAccessRights:#(writeUser writeGroup writeOthers). |
|
664 |
'foo' asFilename addAccessRights:#(executeUser executeGroup executeOthers). |
|
665 |
" |
|
666 |
! |
|
667 |
||
668 |
copyTo:newName |
|
669 |
"copy the file - the argument must be convertable to a filename. |
|
670 |
Return true if successfull, false if not." |
|
671 |
||
672 |
|inStream outStream buffer bufferSize count newFile| |
|
673 |
||
674 |
bufferSize := 8 * 1024. |
|
675 |
buffer := ByteArray new:bufferSize. |
|
676 |
inStream := self readStream. |
|
677 |
inStream isNil ifTrue:[ |
|
678 |
^ self fileNotFoundError:self |
|
679 |
]. |
|
680 |
||
681 |
outStream := (newFile := newName asFilename) writeStream. |
|
682 |
outStream isNil ifTrue:[ |
|
683 |
^ self fileCreationError:newFile |
|
684 |
]. |
|
685 |
||
686 |
[inStream atEnd] whileFalse:[ |
|
687 |
count := inStream nextBytes:bufferSize into:buffer. |
|
688 |
(outStream nextPutBytes:count from:buffer) ~= count ifTrue:[ |
|
689 |
^ self fileCreationError:newFile |
|
690 |
] |
|
691 |
]. |
|
692 |
outStream close. |
|
693 |
inStream close. |
|
694 |
||
695 |
" |
|
696 |
'Makefile' asFilename copyTo:'Makefile.foo' |
|
697 |
'smalltalk' asFilename copyTo:'/dev/null' |
|
698 |
" |
|
699 |
! |
|
700 |
||
701 |
delete |
|
702 |
"remove the file - same as remove, for ST-80 compatibility" |
|
703 |
||
704 |
self remove |
|
705 |
! |
|
706 |
||
707 |
makeDirectory |
|
708 |
"create a directory with the receivers name. |
|
709 |
Return true if successfull, false if not." |
|
710 |
||
711 |
(OperatingSystem createDirectory:nameString) ifFalse:[ |
|
712 |
^ self fileCreationError:self |
|
713 |
] |
|
714 |
! |
|
715 |
||
716 |
makeReadable |
|
717 |
"make the file readable for the owner - you must have permission to do so." |
|
718 |
||
719 |
^ self addAccessRights:#(readUser) |
|
720 |
! |
|
721 |
||
722 |
makeReadableForAll |
|
723 |
"make the file readable for all - you must have permission to do so." |
|
724 |
||
725 |
^ self addAccessRights:#(readUser readGroup readOthers) |
|
726 |
! |
|
727 |
||
728 |
makeUnwritable |
|
729 |
"make the file unwritable for all - you must have permission to do so." |
|
730 |
||
731 |
^ self removeAccessRights:#(writeUser writeGroup writeOthers) |
|
732 |
! |
|
733 |
||
734 |
makeWritable |
|
735 |
"make the file writableable for all - you must have permission to do so." |
|
736 |
||
737 |
^ self addAccessRights:#(writeUser) |
|
738 |
! |
|
739 |
||
740 |
makeWritableForAll |
|
741 |
"make the file writable for all - you must have permission to do so." |
|
742 |
||
743 |
^ self addAccessRights:#(writeUser writeGroup writeOthers) |
|
744 |
! |
|
745 |
||
746 |
moveTo:newName |
|
747 |
"copy the file represented by the receiver, then delete it. |
|
748 |
This is different to renaming in case of cross device moves. |
|
749 |
Return true if successfull, false if not." |
|
750 |
||
751 |
self copyTo:newName. |
|
752 |
self remove |
|
753 |
! |
|
754 |
||
755 |
recursiveRemove |
|
756 |
"remove the directory and all of its subfiles/subdirectories." |
|
757 |
||
758 |
|ok| |
|
759 |
||
760 |
ok := OperatingSystem recursiveRemoveDirectory:nameString. |
|
761 |
ok ifFalse:[ |
|
762 |
self removeError:self |
|
763 |
]. |
|
764 |
||
765 |
" |
|
766 |
'foo' asFilename makeDirectory. |
|
767 |
'foo/bar' asFilename writeStream close. |
|
768 |
('foo' asFilename remove) ifFalse:[ |
|
769 |
Transcript showCr:'could not remove foo' |
|
770 |
] |
|
771 |
" |
|
772 |
" |
|
773 |
'foo' asFilename makeDirectory. |
|
774 |
'foo/bar' asFilename writeStream close. |
|
775 |
('foo' asFilename recursiveRemove) ifFalse:[ |
|
776 |
Transcript showCr:'could not remove foo' |
|
777 |
] |
|
778 |
" |
|
779 |
||
780 |
"Created: 14.11.1995 / 11:19:29 / cg" |
|
781 |
! |
|
782 |
||
783 |
remove |
|
784 |
"remove the file/directory - the argument must be convertable to a String. |
|
785 |
Return true if sucessfull, false if not. |
|
786 |
Use recursiveRemove in order to (recursively) remove non empty directories." |
|
787 |
||
788 |
|ok| |
|
789 |
||
790 |
self exists ifFalse:[ ^ self]. |
|
791 |
self isDirectory ifTrue:[ |
|
792 |
ok := OperatingSystem removeDirectory:nameString |
|
793 |
] ifFalse:[ |
|
794 |
ok := OperatingSystem removeFile:nameString |
|
795 |
]. |
|
796 |
ok ifFalse:[ |
|
797 |
self removeError:self |
|
798 |
]. |
|
799 |
||
800 |
" |
|
801 |
(FileStream newFileNamed:'foo') close. |
|
802 |
'foo' asFilename remove |
|
803 |
" |
|
804 |
||
805 |
" |
|
806 |
'foo' asFilename makeDirectory. |
|
807 |
'foo/bar' asFilename writeStream close. |
|
808 |
('foo' asFilename remove) ifFalse:[ |
|
809 |
Transcript showCr:'could not remove foo' |
|
810 |
] |
|
811 |
" |
|
812 |
||
813 |
"Modified: 14.11.1995 / 11:18:26 / cg" |
|
814 |
! |
|
815 |
||
816 |
removeAccessRights:aCollection |
|
817 |
"remove the access rights as specified in aCollection for the file represented |
|
818 |
by the receiver. The argument must be a collection of symbols, |
|
819 |
such as #readUser, #writeGroup etc." |
|
820 |
||
821 |
|access| |
|
822 |
||
823 |
access := OperatingSystem accessModeOf:nameString. |
|
824 |
aCollection do:[:accessSymbol | |
|
825 |
access := access bitAnd:(OperatingSystem accessMaskFor:accessSymbol) bitInvert. |
|
826 |
]. |
|
827 |
(OperatingSystem changeAccessModeOf:nameString to:access) ifFalse:[ |
|
828 |
^ self accessDeniedError:self |
|
829 |
]. |
|
830 |
||
831 |
" |
|
832 |
'foo' asFilename writeStream close. |
|
833 |
'foo' asFilename removeAccessRights:#(readUser readGroup readOthers). |
|
834 |
'foo' asFilename removeAccessRights:#(writeUser writeGroup writeOthers). |
|
835 |
'foo' asFilename removeAccessRights:#(executeUser executeGroup executeOthers). |
|
836 |
" |
|
837 |
! |
|
838 |
||
839 |
renameTo:newName |
|
840 |
"rename the file - the argument must be convertable to a String." |
|
841 |
||
842 |
|ok| |
|
843 |
||
844 |
ok := OperatingSystem renameFile:nameString to:(newName asString). |
|
845 |
ok ifFalse:[ |
|
846 |
self exists ifFalse:[ |
|
847 |
^ self fileNotFoundError:self |
|
848 |
]. |
|
849 |
^ self accessDeniedError:newName asFilename. |
|
850 |
]. |
|
851 |
||
852 |
" |
|
853 |
'/tmp/foo' asFilename renameTo:'/tmp/bar' |
|
854 |
" |
|
855 |
! ! |
|
856 |
||
857 |
!Filename methodsFor:'file queries'! |
|
858 |
||
859 |
dates |
|
860 |
"return the files modification and access times as an object (currently a dictionary) |
|
861 |
that responds to the at: message with arguments |
|
862 |
#modified, #accessed or #statusChanged." |
|
863 |
||
864 |
|info dates| |
|
865 |
||
866 |
info := OperatingSystem infoOf:nameString. |
|
867 |
info isNil ifTrue:[ |
|
868 |
info := OperatingSystem linkInfoOf:nameString. |
|
869 |
info isNil ifTrue:[ |
|
870 |
^ nil |
|
871 |
] |
|
872 |
]. |
|
873 |
dates := IdentityDictionary new. |
|
874 |
dates at:#modified put:(info at:#modified). |
|
875 |
dates at:#accessed put:(info at:#accessed). |
|
876 |
dates at:#statusChanged put:(info at:#statusChanged). |
|
877 |
^ dates |
|
878 |
||
879 |
" |
|
880 |
Filename currentDirectory dates |
|
881 |
'../regression' asFilename dates |
|
882 |
" |
|
883 |
! |
|
884 |
||
885 |
fileSize |
|
886 |
"return the size of the file in bytes" |
|
887 |
||
888 |
|info| |
|
889 |
||
890 |
info := self info. |
|
891 |
info isNil ifTrue:[^ nil]. |
|
892 |
^ info at:#size |
|
893 |
! |
|
894 |
||
895 |
fileType |
|
896 |
"this returns a string describing the type of contents of |
|
897 |
the file. This is done using the unix 'file' command, |
|
898 |
(which usually is configurable by /etc/magic). |
|
899 |
On non-unix systems, this may return an empty string, not knowning |
|
900 |
about the contents." |
|
901 |
||
902 |
|stream typeString| |
|
903 |
||
904 |
typeString := ''. |
|
905 |
stream := PipeStream readingFrom:('file ' , self pathName). |
|
906 |
stream notNil ifTrue:[ |
|
907 |
typeString := stream contents asString. |
|
908 |
stream close. |
|
909 |
typeString := typeString copyFrom:(typeString indexOf:$:) + 1. |
|
910 |
typeString := typeString withoutSeparators |
|
911 |
] ifFalse:[ |
|
912 |
" |
|
913 |
could add some fallback code here, for systems, where no |
|
914 |
file command is avaliable ... |
|
915 |
... or at least analyze directory info. |
|
916 |
" |
|
917 |
]. |
|
918 |
^ typeString |
|
919 |
||
920 |
" |
|
921 |
'Makefile' asFilename fileType |
|
922 |
'.' asFilename fileType |
|
923 |
'/dev/null' asFilename fileType |
|
924 |
'smalltalk.rc' asFilename fileType |
|
925 |
'bitmaps/SBrowser.xbm' asFilename fileType |
|
926 |
" |
|
927 |
! |
|
928 |
||
929 |
info |
|
930 |
"return the files info; that is a collection of file attributes, |
|
931 |
(actually a dictionary) where the keys are #type, #uid, #gid, #size etc. |
|
932 |
The actual amount and detail returned may depend on the OS used. |
|
933 |
On unix, if you ask for the info of a symbolic link, the target |
|
934 |
files info is returned. (see also: #linkInfo) |
|
935 |
||
936 |
On unix, the contents is: |
|
937 |
id -> the inode number (integer) |
|
938 |
uid -> the numeric user id of the files owner |
|
939 |
gid -> the numeric group id of the files owner |
|
940 |
statusChanged -> the absoluteTime when the files status changed last |
|
941 |
(i.e. protection change, owner change etc.) |
|
942 |
accessed -> the absoluteTime when the file was last accessed |
|
943 |
modified -> the absoluteTime when the file was last modified |
|
944 |
size -> the size (in bytes) of the file |
|
945 |
type -> the files type (#regular, #directory, #characterSpecial) |
|
946 |
mode -> the files access protection bits (rwxrwxrwx mask). |
|
947 |
||
948 |
The minimum returned info (i.e. on all OS's) will consist of at least: |
|
949 |
modified |
|
950 |
size |
|
951 |
type |
|
952 |
||
953 |
Some OS's (VMS) may return more info. |
|
954 |
||
955 |
Dont expect things like uid/gid/mode to be there; write your application |
|
956 |
to either handle the cases where info-entries are not present, |
|
957 |
or (better) use one of isXXXX query methods. (Be prepared for DOS ...) |
|
958 |
" |
|
959 |
||
960 |
^ OperatingSystem infoOf:nameString |
|
961 |
||
962 |
" |
|
963 |
Filename currentDirectory info |
|
964 |
'/dev/null' asFilename info |
|
965 |
'Make.proto' asFilename info |
|
966 |
'source/Point.st' asFilename info |
|
967 |
'source/Point.st' asFilename linkInfo |
|
968 |
'../../libbasic/Point.st' asFilename info |
|
969 |
" |
|
970 |
! |
|
971 |
||
972 |
linkInfo |
|
973 |
"return the files info if its a symbolic link; nil otherwise. |
|
974 |
On OS's which do not support symbolic links, nil is always returned. |
|
975 |
The information is the same as returned by #info, except that if the |
|
976 |
receiver represents a symbolic link, the links information |
|
977 |
is returned |
|
978 |
(while in this case, #info returns the info of the target file, |
|
979 |
which is accessed via the symbolic link). |
|
980 |
||
981 |
In addition to the normal entries, Unix returns an additional entry: |
|
982 |
path -> the target files pathname |
|
983 |
||
984 |
See the comment in #info for more details." |
|
985 |
||
986 |
^ OperatingSystem linkInfoOf:nameString |
|
987 |
||
988 |
" |
|
989 |
Filename currentDirectory linkInfo |
|
990 |
'/dev/null' asFilename linkInfo |
|
991 |
'Make.proto' asFilename linkInfo |
|
992 |
'Make.proto' asFilename linkInfo at:#path |
|
993 |
'source/Point.st' asFilename linkInfo |
|
994 |
'../../libbasic/Point.st' asFilename linkInfo |
|
995 |
" |
|
996 |
! ! |
|
997 |
||
998 |
!Filename methodsFor:'file utilities'! |
|
999 |
||
1000 |
contentsOfEntireFile |
|
1001 |
"return the contents of the file as a string" |
|
1002 |
||
1003 |
|s contents| |
|
1004 |
||
1005 |
s := self readStream. |
|
1006 |
[ |
|
1007 |
contents := s contents |
|
1008 |
] valueNowOrOnUnwindDo:[s close]. |
|
1009 |
^ contents |
|
1010 |
! |
|
1011 |
||
1012 |
edit |
|
1013 |
"start an editView on the file represented by the receiver" |
|
1014 |
||
1015 |
EditTextView openOn:self asString |
|
1016 |
||
1017 |
" |
|
1018 |
'smalltalk.rc' asFilename edit |
|
1019 |
" |
|
1020 |
! |
|
1021 |
||
1022 |
fileIn |
|
1023 |
"load smalltalk code from the file" |
|
1024 |
||
1025 |
^ self readStream fileIn |
|
542 | 1026 |
! ! |
1027 |
||
2 | 1028 |
!Filename methodsFor:'instance creation'! |
1029 |
||
615 | 1030 |
construct:subname |
1031 |
"taking the receiver as a directory name, construct a new |
|
1032 |
filename for an entry within this directory (i.e. for a file |
|
1033 |
or a subdirectory in that directory)." |
|
1034 |
||
1035 |
^ (self constructString:subname) asFilename |
|
1036 |
||
1037 |
" |
|
1038 |
'/tmp' asFilename construct:'foo' |
|
1039 |
'/' asFilename construct:'foo' |
|
1040 |
'/usr/tmp' asFilename construct:'foo' |
|
1041 |
'/foo/bar' asFilename construct:'baz' |
|
1042 |
" |
|
1043 |
! |
|
1044 |
||
249 | 1045 |
constructString:subname |
38 | 1046 |
"taking the receiver as a directory name, construct a new |
249 | 1047 |
filenames string for an entry within this directory (i.e. for a file |
38 | 1048 |
or a subdirectory in that directory)." |
1049 |
||
276 | 1050 |
|sepString| |
202 | 1051 |
|
1052 |
sepString := self class separator asString. |
|
1053 |
nameString = sepString ifTrue:[ |
|
159 | 1054 |
"I am the root" |
276 | 1055 |
^ sepString , subname |
85 | 1056 |
]. |
422 | 1057 |
^ nameString , sepString , subname asString |
38 | 1058 |
|
85 | 1059 |
" |
249 | 1060 |
'/tmp' asFilename constructString:'foo' |
1061 |
'/' asFilename constructString:'foo' |
|
1062 |
'/usr/tmp' asFilename constructString:'foo' |
|
328 | 1063 |
'/foo/bar' asFilename constructString:'baz' |
249 | 1064 |
" |
422 | 1065 |
|
1066 |
"Modified: 7.9.1995 / 10:15:22 / claus" |
|
2 | 1067 |
! ! |
1068 |
||
195 | 1069 |
!Filename methodsFor:'misc'! |
1070 |
||
1071 |
, aString |
|
1072 |
"this allows filenames to understand how names are concatenated. |
|
308 | 1073 |
Returns a string consisting of the receivers name, concatenated |
195 | 1074 |
by aString. Notice this is NOT the same as construct:, which inserts |
308 | 1075 |
a directory delimiter and returns a new fileName instance." |
195 | 1076 |
|
308 | 1077 |
^ (nameString , aString asString) |
195 | 1078 |
|
1079 |
" |
|
1080 |
'Makefile' asFilename , '.bak' |
|
1081 |
'Makefile' asFilename construct:'.bak' |
|
1082 |
" |
|
1083 |
! ! |
|
1084 |
||
615 | 1085 |
!Filename methodsFor:'printing & storing'! |
174 | 1086 |
|
615 | 1087 |
printOn:aStream |
1088 |
"append a printed representation of the receiver to aStream." |
|
174 | 1089 |
|
615 | 1090 |
aStream nextPutAll:'FileName('''. |
1091 |
nameString printOn:aStream. |
|
1092 |
aStream nextPutAll:''')' |
|
1 | 1093 |
! |
1094 |
||
615 | 1095 |
storeOn:aStream |
1096 |
"append a printed representation of the receiver to aStream, |
|
1097 |
which allows reconstructing it via readFrom:" |
|
328 | 1098 |
|
615 | 1099 |
aStream nextPut:$(. |
1100 |
nameString storeOn:aStream. |
|
1101 |
aStream nextPutAll:' asFilename)' |
|
1 | 1102 |
! ! |
1103 |
||
202 | 1104 |
!Filename methodsFor:'private accessing'! |
1 | 1105 |
|
68 | 1106 |
setName:aString |
38 | 1107 |
"set the filename" |
1108 |
||
68 | 1109 |
nameString := aString |
1 | 1110 |
! ! |
1111 |
||
2 | 1112 |
!Filename methodsFor:'queries'! |
1113 |
||
615 | 1114 |
baseName |
1115 |
"return my baseName as a string. |
|
1116 |
- thats the file/directory name without leading parent-dirs." |
|
159 | 1117 |
|
615 | 1118 |
^ OperatingSystem baseNameOf:nameString "/ (self pathName) |
422 | 1119 |
|
1120 |
" |
|
615 | 1121 |
'/foo/bar' asFilename baseName |
1122 |
'.' asFilename baseName |
|
1123 |
'..' asFilename baseName |
|
1124 |
'../..' asFilename baseName |
|
1125 |
'../../libbasic' asFilename baseName |
|
1126 |
'../../libpr' asFilename baseName |
|
1127 |
'../../libbasic/Object.st' asFilename baseName |
|
422 | 1128 |
" |
1129 |
! |
|
1130 |
||
615 | 1131 |
canBeWritten |
1132 |
"same as isWritable - for ST-80 compatibility" |
|
328 | 1133 |
|
615 | 1134 |
^ self isWritable |
92 | 1135 |
|
328 | 1136 |
" |
615 | 1137 |
'/foo/bar' asFilename canBeWritten |
1138 |
'/tmp' asFilename canBeWritten |
|
1139 |
'Makefile' asFilename canBeWritten |
|
328 | 1140 |
" |
1141 |
! |
|
1142 |
||
1143 |
directory |
|
422 | 1144 |
"return the directory name part of the file/directory as a filename. |
328 | 1145 |
- thats a filename for the directory where the file/dir represented by |
1146 |
the receiver is contained in." |
|
1147 |
||
1148 |
^ self directoryName asFilename |
|
2 | 1149 |
|
92 | 1150 |
" |
174 | 1151 |
'/foo/bar' asFilename directory |
1152 |
'.' asFilename directory |
|
1153 |
'..' asFilename directory |
|
1154 |
'../..' asFilename directory |
|
92 | 1155 |
" |
2 | 1156 |
! |
1157 |
||
308 | 1158 |
directoryContents |
1159 |
"return the contents of the directory as a collection of strings" |
|
1160 |
||
1161 |
^ (FileDirectory directoryNamed:self asString) contents |
|
1162 |
||
1163 |
" |
|
1164 |
'.' asFilename directoryContents |
|
1165 |
" |
|
1166 |
! |
|
1167 |
||
615 | 1168 |
directoryName |
1169 |
"return the directory name part of the file/directory as a string. |
|
1170 |
- thats the name of the directory where the file/dir represented by |
|
1171 |
the receiver is contained in. |
|
1172 |
See also: #directoryPathName" |
|
174 | 1173 |
|
615 | 1174 |
^ OperatingSystem directoryNameOf:nameString "/ (self pathName) |
68 | 1175 |
|
85 | 1176 |
" |
615 | 1177 |
'/foo/bar/' asFilename directoryName |
1178 |
'/foo/bar' asFilename directoryName |
|
1179 |
'bitmaps' asFilename directoryName |
|
1180 |
'bitmaps' asFilename directoryPathName |
|
1181 |
'.' asFilename directoryName |
|
1182 |
'..' asFilename directoryName |
|
1183 |
'../..' asFilename directoryName |
|
1184 |
'../..' asFilename directoryPathName |
|
422 | 1185 |
" |
1186 |
||
615 | 1187 |
"Modified: 7.9.1995 / 10:42:03 / claus" |
422 | 1188 |
! |
1189 |
||
615 | 1190 |
directoryPathName |
1191 |
"return the full directory pathname part of the file/directory as a string. |
|
1192 |
- thats the full pathname of the directory where the file/dir represented by |
|
1193 |
the receiver is contained in. |
|
1194 |
See also: directoryName" |
|
216 | 1195 |
|
615 | 1196 |
^ OperatingSystem directoryNameOf:(self pathName) |
92 | 1197 |
|
1198 |
" |
|
615 | 1199 |
'/foo/bar/' asFilename directoryPathName |
1200 |
'/foo/bar' asFilename directoryPathName |
|
1201 |
'.' asFilename directoryPathName |
|
1202 |
'..' asFilename directoryPathName |
|
1203 |
'../..' asFilename directoryPathName |
|
85 | 1204 |
" |
422 | 1205 |
|
615 | 1206 |
"Modified: 7.9.1995 / 10:42:13 / claus" |
68 | 1207 |
! |
1208 |
||
1209 |
exists |
|
92 | 1210 |
"return true, if such a file exists." |
68 | 1211 |
|
1212 |
^ OperatingSystem isValidPath:nameString |
|
1213 |
||
85 | 1214 |
" |
92 | 1215 |
'/foo/bar' asFilename exists |
1216 |
'/tmp' asFilename exists |
|
1217 |
'Makefile' asFilename exists |
|
85 | 1218 |
" |
77 | 1219 |
! |
1220 |
||
92 | 1221 |
filenameCompletion |
440 | 1222 |
"try to complete the recevier filename. |
1223 |
This method has both a return value and a side effect on the receiver: |
|
1224 |
it returns a collection of matching filename objects, |
|
1225 |
and leaves changes the receivers filename-string to the longest common |
|
1226 |
match. |
|
1227 |
If none matches, the returned collection is empty and the recevier is unchanged. |
|
1228 |
If there is only one match, the size of the returned collection is exactly 1, |
|
1229 |
containing the fully expanded filename and the receivers name is changed to it." |
|
92 | 1230 |
|
440 | 1231 |
^ self filenameCompletionIn:nil |
216 | 1232 |
|
440 | 1233 |
" |
1234 |
'mak' asFilename filenameCompletion |
|
1235 |
'Make' asFilename filenameCompletion |
|
1236 |
'Makef' asFilename filenameCompletion;yourself |
|
1237 |
'/u' asFilename filenameCompletion |
|
1238 |
'../../libpr' asFilename inspect filenameCompletion |
|
1239 |
" |
|
1240 |
! |
|
92 | 1241 |
|
440 | 1242 |
filenameCompletionIn:aDirectory |
1243 |
"try to complete the recevier filename. |
|
1244 |
This method has both a return value and a side effect on the receiver: |
|
1245 |
it returns a collection of matching filename objects, |
|
1246 |
and leaves changes the receivers filename-string to the longest common |
|
1247 |
match. |
|
1248 |
If none matches, the returned collection is empty and the recevier is unchanged. |
|
1249 |
If there is only one match, the size of the returned collection is exactly 1, |
|
1250 |
containing the fully expanded filename and the receivers name is changed to it." |
|
1251 |
||
1252 |
|dir baseName matching matchLen try allMatching |
|
1253 |
sepString parentString prefix nMatch| |
|
1254 |
||
1255 |
sepString := self class separator asString. |
|
1256 |
(nameString endsWith:sepString) ifTrue:[ |
|
1257 |
^ #() |
|
328 | 1258 |
]. |
1259 |
||
440 | 1260 |
parentString := self class parentDirectoryName. |
1261 |
baseName := self baseName. |
|
1262 |
baseName ~= nameString ifTrue:[ |
|
1263 |
prefix := self directoryName. |
|
1264 |
]. |
|
1265 |
||
441 | 1266 |
self isAbsolute ifTrue:[ |
440 | 1267 |
dir := self directory |
1268 |
] ifFalse:[ |
|
441 | 1269 |
aDirectory isNil ifTrue:[ |
1270 |
dir := self directory |
|
1271 |
] ifFalse:[ |
|
1272 |
dir := (aDirectory construct:nameString) directory |
|
1273 |
] |
|
328 | 1274 |
]. |
216 | 1275 |
|
92 | 1276 |
matching := OrderedCollection new. |
440 | 1277 |
dir directoryContents do:[:fileName | |
1278 |
((fileName ~= '.') and:[fileName ~= parentString]) ifTrue:[ |
|
1279 |
(fileName startsWith:baseName) ifTrue:[ |
|
216 | 1280 |
matching add:fileName |
1281 |
] |
|
159 | 1282 |
] |
92 | 1283 |
]. |
440 | 1284 |
(nMatch := matching size) > 1 ifTrue:[ |
1285 |
" |
|
1286 |
find the longest common prefix |
|
1287 |
" |
|
1288 |
matchLen := baseName size. |
|
1289 |
matchLen > matching first size ifTrue:[ |
|
1290 |
try := baseName. |
|
1291 |
allMatching := false |
|
1292 |
] ifFalse:[ |
|
1293 |
try := matching first copyTo:matchLen. |
|
1294 |
allMatching := true. |
|
1295 |
]. |
|
1296 |
||
1297 |
[allMatching] whileTrue:[ |
|
1298 |
matching do:[:aName | |
|
1299 |
(aName startsWith:try) ifFalse:[ |
|
1300 |
allMatching := false |
|
1301 |
] |
|
1302 |
]. |
|
1303 |
allMatching ifTrue:[ |
|
1304 |
matchLen < matching first size ifTrue:[ |
|
1305 |
matchLen := matchLen + 1. |
|
1306 |
try := matching first copyTo:matchLen. |
|
1307 |
] ifFalse:[ |
|
1308 |
allMatching := false |
|
1309 |
] |
|
1310 |
] ifFalse:[ |
|
1311 |
try := matching first copyTo:matchLen - 1. |
|
1312 |
] |
|
1313 |
]. |
|
1314 |
" |
|
1315 |
and set my name to the last full match |
|
1316 |
" |
|
1317 |
nameString := try |
|
1318 |
]. |
|
1319 |
||
92 | 1320 |
" |
440 | 1321 |
if I had a directory-prefix, change names in collection ... |
1322 |
" |
|
1323 |
prefix notNil ifTrue:[ |
|
1324 |
prefix = '/' ifTrue:[ |
|
1325 |
"/ avoid introducing double slashes |
|
1326 |
prefix := '' |
|
159 | 1327 |
]. |
440 | 1328 |
matching := matching collect:[:n | prefix , '/' , n]. |
1329 |
nMatch == 1 ifTrue:[ |
|
1330 |
nameString := matching first |
|
1331 |
] ifFalse:[ |
|
1332 |
nMatch > 1 ifTrue:[ |
|
1333 |
nameString := prefix , '/' , nameString |
|
159 | 1334 |
] |
1335 |
] |
|
92 | 1336 |
] ifFalse:[ |
440 | 1337 |
nMatch == 1 ifTrue:[ |
1338 |
nameString := matching first |
|
159 | 1339 |
] |
92 | 1340 |
]. |
440 | 1341 |
|
92 | 1342 |
" |
1343 |
return the match-set, so caller can decide what to do |
|
1344 |
(i.e. show the matches, output a warning etc ...) |
|
1345 |
" |
|
1346 |
^ matching |
|
1347 |
||
440 | 1348 |
" trivial cases: |
1349 |
||
1350 |
'../' asFilename filenameCompletion |
|
1351 |
'/' asFilename filenameCompletion |
|
1352 |
'/usr/' asFilename filenameCompletion |
|
1353 |
||
1354 |
'mak' asFilename filenameCompletion |
|
1355 |
'Make' asFilename filenameCompletion |
|
1356 |
'Makef' asFilename filenameCompletion |
|
1357 |
'/u' asFilename filenameCompletion |
|
1358 |
'../../libpr' asFilename filenameCompletion |
|
85 | 1359 |
" |
615 | 1360 |
! |
174 | 1361 |
|
615 | 1362 |
filesMatching:aPattern |
1363 |
^ self directoryContents select:[:name | aPattern match:name] |
|
356 | 1364 |
|
615 | 1365 |
" |
1366 |
Filename currentDirectory filesMatching:'M*' |
|
1367 |
" |
|
1368 |
! |
|
356 | 1369 |
|
615 | 1370 |
isAbsolute |
1371 |
"return true, if the receiver represents an absolute pathname |
|
1372 |
(in contrast to one relative to the current directory)." |
|
356 | 1373 |
|
615 | 1374 |
^ (nameString startsWith:self class separator) |
328 | 1375 |
|
1376 |
" |
|
615 | 1377 |
'/foo/bar' asFilename isAbsolute |
1378 |
'..' asFilename isAbsolute |
|
1379 |
'..' asAbsoluteFilename isAbsolute |
|
1380 |
'source/SBrowser.st' asFilename isAbsolute |
|
1381 |
" |
|
1382 |
! |
|
1383 |
||
1384 |
isDirectory |
|
1385 |
"return true, if the receiver represents an existing, |
|
1386 |
readable directories pathname." |
|
1387 |
||
1388 |
^ OperatingSystem isDirectory:nameString |
|
1389 |
||
1390 |
" |
|
1391 |
'/foo/bar' asFilename isDirectory |
|
1392 |
'/tmp' asFilename isDirectory |
|
1393 |
'Makefile' asFilename isDirectory |
|
1394 |
" |
|
1395 |
! |
|
1396 |
||
1397 |
isExecutable |
|
1398 |
"return true, if such a file exists and is executable (by Unix's definition). |
|
1399 |
For directories, true is returned if the directory can be entered. |
|
1400 |
See isExecutableProgram for a related check." |
|
1401 |
||
1402 |
^ OperatingSystem isExecutable:nameString |
|
1403 |
||
1404 |
" |
|
1405 |
'/foo/bar' asFilename isExecutable |
|
1406 |
'/tmp' asFilename isExecutable |
|
1407 |
'Makefile' asFilename isExecutable |
|
1408 |
'/bin/ls' asFilename isExecutable |
|
356 | 1409 |
" |
1410 |
! |
|
1411 |
||
615 | 1412 |
isExecutableProgram |
1413 |
"return true, if such a file exists and is an executable program. |
|
1414 |
(i.e. for directories, false is returned.)" |
|
356 | 1415 |
|
615 | 1416 |
^ (OperatingSystem isExecutable:nameString) |
1417 |
and:[(OperatingSystem isDirectory:nameString) not] |
|
356 | 1418 |
|
1419 |
" |
|
615 | 1420 |
'/tmp' asFilename isExecutable |
1421 |
'/bin/ls' asFilename isExecutable |
|
1422 |
'/tmp' asFilename isExecutableProgram |
|
1423 |
'/bin/ls' asFilename isExecutableProgram |
|
1424 |
" |
|
1425 |
! |
|
1426 |
||
1427 |
isReadable |
|
1428 |
"return true, if such a file exists and is readable." |
|
1429 |
||
1430 |
^ OperatingSystem isReadable:nameString |
|
1431 |
||
1432 |
" |
|
1433 |
'/foo/bar' asFilename isReadable |
|
1434 |
'/tmp' asFilename isReadable |
|
1435 |
'Makefile' asFilename isReadable |
|
328 | 1436 |
" |
1437 |
! |
|
1438 |
||
615 | 1439 |
isRelative |
1440 |
"return true, if this name is interpreted relative to some |
|
1441 |
directory (opposite of absolute)" |
|
328 | 1442 |
|
615 | 1443 |
^ self isAbsolute not |
1444 |
! |
|
328 | 1445 |
|
615 | 1446 |
isSymbolicLink |
1447 |
"return true, if the file represented by the receiver is a symbolic |
|
1448 |
link. Notice that not all OS's support symbolic links; those that do |
|
1449 |
not will always return false." |
|
1450 |
||
1451 |
^ OperatingSystem isSymbolicLink:nameString |
|
328 | 1452 |
|
1453 |
" |
|
615 | 1454 |
'Make.proto' asFilename isSymbolicLink |
1455 |
'Makefile' asFilename isSymbolicLink |
|
1456 |
" |
|
1457 |
! |
|
1458 |
||
1459 |
isWritable |
|
1460 |
"return true, if such a file exists and is writable." |
|
1461 |
||
1462 |
^ OperatingSystem isWritable:nameString |
|
1463 |
||
1464 |
" |
|
1465 |
'/foo/bar' asFilename isWritable |
|
1466 |
'/tmp' asFilename isWritable |
|
1467 |
'Makefile' asFilename isWritable |
|
328 | 1468 |
" |
174 | 1469 |
! |
1470 |
||
615 | 1471 |
name |
1472 |
"return the name of the file represented by the receiver as a string. |
|
1473 |
This may or may not be a relative name. |
|
1474 |
See also: pathName" |
|
174 | 1475 |
|
615 | 1476 |
self isAbsolute ifTrue:[^ self pathName]. |
1477 |
^ nameString |
|
174 | 1478 |
|
1479 |
" |
|
615 | 1480 |
'/foo/bar' asFilename name |
1481 |
'/foo/bar' asFilename pathName |
|
1482 |
'.' asFilename name |
|
1483 |
'.' asFilename pathName |
|
1484 |
'../..' asFilename name |
|
1485 |
'../..' asFilename pathName |
|
1486 |
'bitmaps' asFilename name |
|
1487 |
'bitmaps' asFilename pathName |
|
1488 |
'/tmp/../usr' asFilename name |
|
1489 |
'/tmp/../usr' asFilename pathName |
|
92 | 1490 |
" |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1491 |
|
615 | 1492 |
"Modified: 7.9.1995 / 10:41:14 / claus" |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1493 |
! |
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1494 |
|
615 | 1495 |
pathName |
1496 |
"return the full pathname of the file represented by the receiver, |
|
1497 |
as a string. See also: name" |
|
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1498 |
|
615 | 1499 |
|parentName sep| |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1500 |
|
615 | 1501 |
sep := self class separator. |
1502 |
(nameString startsWith:sep) ifTrue:[ |
|
1503 |
parentName := self class parentDirectoryName. |
|
1504 |
(nameString findString:parentName) == 0 ifTrue:[ |
|
1505 |
^ nameString |
|
1506 |
] |
|
542 | 1507 |
]. |
615 | 1508 |
^ (FileDirectory directoryNamed:nameString) pathName |
2 | 1509 |
|
92 | 1510 |
" |
615 | 1511 |
'/foo/bar' asFilename pathName |
1512 |
'.' asFilename pathName |
|
1513 |
'../..' asFilename pathName |
|
1514 |
'../..' asFilename name |
|
1515 |
'/tmp/../usr' asFilename pathName |
|
92 | 1516 |
" |
159 | 1517 |
|
615 | 1518 |
"Modified: 7.9.1995 / 10:42:39 / claus" |
174 | 1519 |
! |
1520 |
||
615 | 1521 |
prefixAndSuffix |
1522 |
"return an array consisting of my prefix and suffix. |
|
1523 |
The suffix is the namepart after the final period character, |
|
1524 |
the prefix everything before, except for the period. |
|
1525 |
(on some systems, the suffix-character may be different from a period). |
|
1526 |
For example, foo.bar.baz has a prefix of 'foo.bar' and a suffix of '.baz'. |
|
174 | 1527 |
|
615 | 1528 |
Notice: there is currently no known system which uses other than |
1529 |
the period character as suffixCharacter." |
|
174 | 1530 |
|
615 | 1531 |
|nm idx| |
174 | 1532 |
|
615 | 1533 |
nm := self baseName. |
1534 |
idx := nm lastIndexOf:(self class suffixSeparator). |
|
1535 |
idx == 0 ifTrue:[ |
|
1536 |
^ Array with:nm with:'' |
|
174 | 1537 |
]. |
615 | 1538 |
^ Array |
1539 |
with:(nm copyTo:idx-1) |
|
1540 |
with:(nm copyFrom:idx+1) |
|
174 | 1541 |
|
1542 |
" |
|
615 | 1543 |
'abc.st' asFilename prefixAndSuffix |
1544 |
'abc' asFilename prefixAndSuffix |
|
1545 |
'a.b.c' asFilename prefixAndSuffix |
|
1546 |
||
1547 |
|parts| |
|
1548 |
parts := 'Object.st' asFilename prefixAndSuffix. |
|
1549 |
((parts at:1) , '.o') asFilename |
|
174 | 1550 |
" |
615 | 1551 |
|
1552 |
"Modified: 7.9.1995 / 11:15:42 / claus" |
|
174 | 1553 |
! |
1554 |
||
615 | 1555 |
separator |
1556 |
"return the directory-separator character (or string)" |
|
174 | 1557 |
|
615 | 1558 |
^ self class separator |
174 | 1559 |
! |
1560 |
||
615 | 1561 |
suffix |
1562 |
"return my suffix. |
|
1563 |
The suffix is the namepart after the final period character, |
|
1564 |
or the empty string, if the name does not contain a period." |
|
1565 |
||
1566 |
^ self prefixAndSuffix at:2 |
|
174 | 1567 |
|
615 | 1568 |
" |
1569 |
'abc.st' asFilename suffix |
|
1570 |
'abc' asFilename suffix |
|
1571 |
'a.b.c' asFilename suffix |
|
1572 |
" |
|
174 | 1573 |
|
615 | 1574 |
"Modified: 7.9.1995 / 11:09:03 / claus" |
174 | 1575 |
! |
1576 |
||
615 | 1577 |
tail |
1578 |
"the files name without directory prefix as a string. |
|
1579 |
An alias for baseName, for ST-80 compatiblity." |
|
174 | 1580 |
|
615 | 1581 |
^ self baseName |
174 | 1582 |
! ! |
1583 |