author | Claus Gittinger <cg@exept.de> |
Fri, 15 Jan 1999 21:19:21 +0100 | |
changeset 3954 | 20cc39f4e75c |
parent 3893 | 2d701f7a02db |
child 3958 | e5e1b16f33b6 |
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 |
|
844 | 14 |
instanceVariableNames:'nameString' |
2906 | 15 |
classVariableNames:'NextTempFilenameIndex ConcreteClass' |
844 | 16 |
poolDictionaries:'' |
17 |
category:'System-Support' |
|
615 | 18 |
! |
1 | 19 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
20 |
!Filename class methodsFor:'documentation'! |
88 | 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 |
||
2911 | 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 |
||
2911 | 55 |
'Makefile' asFilename readStream |
56 |
||
57 |
'newFile' asFilename writeStream |
|
58 |
||
59 |
Filename newTemporary writeStream |
|
276 | 60 |
|
1318 | 61 |
Beside lots of protocol to query for a files attributes, the class |
62 |
protocol offers methods for filename completion, to construct pathes |
|
63 |
(in an OS-independent way) and to create temporary files. |
|
2911 | 64 |
Especially the path-construction methods (i.e. #construct:) are highly |
1318 | 65 |
recommended in order to avoid having OS details (like directory separators |
66 |
being slash or backslash) spreaded in your application. |
|
67 |
||
1286 | 68 |
[author:] |
2911 | 69 |
Claus Gittinger |
276 | 70 |
|
1286 | 71 |
[see also:] |
2911 | 72 |
String |
73 |
FileStream DirectoryStream PipeStream Socket |
|
74 |
OperatingSystem |
|
75 |
Date Time |
|
88 | 76 |
" |
360 | 77 |
! |
78 |
||
79 |
examples |
|
80 |
" |
|
81 |
does a file/directory exist ?: |
|
82 |
||
2911 | 83 |
|f| |
84 |
||
85 |
f := 'foobar' asFilename. |
|
86 |
^ f exists |
|
360 | 87 |
|
88 |
||
89 |
is it a directory ?: |
|
90 |
||
2911 | 91 |
|f| |
92 |
||
93 |
f := '/tmp' asFilename. |
|
94 |
^ f isDirectory. |
|
360 | 95 |
|
96 |
||
97 |
get the working directory: |
|
98 |
||
2911 | 99 |
^ Filename defaultDirectory |
360 | 100 |
|
101 |
||
102 |
get a files full pathname |
|
103 |
(caring for relative names or symbolic links): |
|
104 |
||
2911 | 105 |
|f| |
106 |
||
107 |
f := '..' asFilename. |
|
108 |
^ f pathName |
|
360 | 109 |
|
110 |
||
111 |
get a directories directory: |
|
112 |
||
2911 | 113 |
|f| |
114 |
||
115 |
f := Filename defaultDirectory. |
|
116 |
^ f directory |
|
360 | 117 |
|
118 |
||
119 |
get a files directory: |
|
120 |
||
2911 | 121 |
|f| |
122 |
||
123 |
f := './smalltalk' asFilename. |
|
124 |
^ f directory |
|
360 | 125 |
|
126 |
||
127 |
getting access & modification times: |
|
128 |
||
129 |
||
2911 | 130 |
|f| |
131 |
||
132 |
f := '/tmp' asFilename. |
|
133 |
^ f dates |
|
360 | 134 |
|
135 |
access time only: |
|
136 |
||
2911 | 137 |
|f| |
138 |
||
139 |
f := '/tmp' asFilename. |
|
140 |
^ f dates at:#accessed |
|
360 | 141 |
|
142 |
||
143 |
getting all information on a file/directory: |
|
144 |
||
145 |
||
2911 | 146 |
|f| |
147 |
||
148 |
f := '/tmp' asFilename. |
|
149 |
^ f info |
|
360 | 150 |
|
151 |
||
152 |
getting a temporary file (unique name): |
|
153 |
||
2911 | 154 |
|f| |
155 |
||
156 |
f := Filename newTemporary. |
|
157 |
^ f |
|
360 | 158 |
|
159 |
||
160 |
creating, writing, reading and removing a temporary file: |
|
2911 | 161 |
[exBegin] |
162 |
|f writeStream readStream| |
|
163 |
||
164 |
f := Filename newTemporary. |
|
165 |
writeStream := f writeStream. |
|
166 |
writeStream nextPutAll:'hello world'. |
|
167 |
writeStream cr. |
|
168 |
writeStream close. |
|
169 |
||
170 |
'contents (as seen by unix''s cat command:' printNL. |
|
171 |
OperatingSystem executeCommand:('cat ' , f pathName). |
|
172 |
||
173 |
readStream := f readStream. |
|
174 |
Transcript showCR:'contents as seen by smalltalk:'. |
|
175 |
Transcript showCR:(readStream upToEnd). |
|
176 |
readStream close. |
|
177 |
||
178 |
f delete. |
|
179 |
[exEnd] |
|
360 | 180 |
|
181 |
||
182 |
getting a directories contents: |
|
2911 | 183 |
[exBegin] |
184 |
|f files| |
|
185 |
||
186 |
f := Filename currentDirectory. |
|
187 |
files := f directoryContents. |
|
188 |
Transcript showCR:'the files are:'. |
|
189 |
Transcript showCR:(files printString). |
|
190 |
[exEnd] |
|
360 | 191 |
|
192 |
||
193 |
editing a file: |
|
2911 | 194 |
[exBegin] |
195 |
|f| |
|
196 |
||
197 |
f := Filename newTemporary. |
|
198 |
(f writeStream) nextPutAll:'hello world'; close. |
|
199 |
||
200 |
f edit |
|
201 |
[exEnd] |
|
360 | 202 |
" |
88 | 203 |
! ! |
1 | 204 |
|
2906 | 205 |
!Filename class methodsFor:'initialization'! |
206 |
||
207 |
initialize |
|
208 |
"initialize for the OS we are running on" |
|
209 |
||
210 |
self initializeConcreteClass |
|
211 |
||
212 |
" |
|
213 |
self initialize |
|
214 |
" |
|
215 |
||
216 |
"Created: 7.9.1997 / 23:32:55 / cg" |
|
217 |
! |
|
218 |
||
219 |
initializeConcreteClass |
|
220 |
"initialize for the OS we are running on" |
|
221 |
||
222 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
223 |
ConcreteClass := PCFilename |
|
224 |
] ifFalse:[ |
|
225 |
OperatingSystem isVMSlike ifTrue:[ |
|
226 |
ConcreteClass := OpenVMSFilename |
|
227 |
] ifFalse:[ |
|
228 |
OperatingSystem isUNIXlike ifTrue:[ |
|
229 |
ConcreteClass := UnixFilename |
|
230 |
] ifFalse:[ |
|
231 |
ConcreteClass := nil |
|
232 |
] |
|
233 |
] |
|
234 |
] |
|
235 |
||
236 |
" |
|
237 |
self initialize |
|
238 |
" |
|
239 |
||
240 |
"Modified: 7.9.1997 / 23:32:37 / cg" |
|
241 |
! |
|
242 |
||
243 |
reinitialize |
|
244 |
"initialize for the OS we are running on" |
|
245 |
||
246 |
self initializeConcreteClass |
|
247 |
||
248 |
" |
|
249 |
self initialize |
|
250 |
" |
|
251 |
||
252 |
"Created: 7.9.1997 / 23:33:02 / cg" |
|
253 |
! ! |
|
254 |
||
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
255 |
!Filename class methodsFor:'instance creation'! |
1 | 256 |
|
276 | 257 |
currentDirectory |
258 |
"return a filename for the current directory" |
|
259 |
||
2906 | 260 |
(self ~~ ConcreteClass) ifTrue:[ |
261 |
^ ConcreteClass currentDirectory |
|
262 |
]. |
|
263 |
||
264 |
"/ fallBack - works on Unix & MSDOS (but not on VMS) |
|
265 |
||
2922 | 266 |
^ self named:'.' |
267 |
"/ ^ self named:('.' asFilename pathName) |
|
276 | 268 |
|
269 |
" |
|
270 |
Filename currentDirectory |
|
271 |
" |
|
2550 | 272 |
|
2906 | 273 |
"Modified: 8.9.1997 / 00:24:15 / cg" |
276 | 274 |
! |
275 |
||
3886
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
276 |
currentDirectoryName |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
277 |
"return a filename for the current directory" |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
278 |
|
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
279 |
(self ~~ ConcreteClass) ifTrue:[ |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
280 |
^ ConcreteClass currentDirectoryName |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
281 |
]. |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
282 |
|
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
283 |
"/ fallBack - works on Unix & MSDOS (but not on VMS) |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
284 |
|
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
285 |
^ '.' |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
286 |
|
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
287 |
" |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
288 |
Filename currentDirectoryName |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
289 |
" |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
290 |
|
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
291 |
"Modified: / 8.9.1997 / 00:24:15 / cg" |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
292 |
"Created: / 21.10.1998 / 17:49:57 / cg" |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
293 |
! |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
294 |
|
328 | 295 |
defaultDirectory |
296 |
"ST80 compatibility: same as currentDirectory" |
|
297 |
||
298 |
^ self currentDirectory |
|
299 |
||
300 |
" |
|
301 |
Filename defaultDirectory |
|
302 |
" |
|
303 |
! |
|
304 |
||
542 | 305 |
defaultDirectoryName |
306 |
"ST80 compatibility: return the defaultDirectories name (as a string)" |
|
307 |
||
308 |
^ self defaultDirectory name |
|
309 |
||
310 |
" |
|
311 |
Filename defaultDirectoryName |
|
312 |
" |
|
313 |
! |
|
314 |
||
2906 | 315 |
defaultTempDirectoryName |
316 |
"return the default temp directory as a filename. |
|
317 |
This is used, if no special preferences were defined in |
|
318 |
any of the TEMP-environment variables (see tempDirectory)." |
|
319 |
||
320 |
(self ~~ ConcreteClass) ifTrue:[ |
|
321 |
^ ConcreteClass defaultTempDirectoryName |
|
322 |
]. |
|
323 |
||
324 |
^ '/tmp' |
|
325 |
||
326 |
" |
|
327 |
Filename defaultTempDirectoryName |
|
328 |
" |
|
329 |
||
330 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
331 |
"Created: 7.3.1996 / 14:51:18 / cg" |
|
332 |
"Modified: 8.9.1997 / 00:24:53 / cg" |
|
333 |
! |
|
334 |
||
2707
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
335 |
findDefaultDirectory |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
336 |
"same as #defaultDirectory for ST80 compatibility" |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
337 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
338 |
^ self defaultDirectory |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
339 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
340 |
"Created: 20.6.1997 / 17:00:29 / cg" |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
341 |
! |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
342 |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
343 |
fromComponents:aCollectionOfDirectoryNames |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
344 |
"create & return a new filename from components given in |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
345 |
aCollectionOfDirectoryNames. If the first component is the name of the |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
346 |
root directory (i.e. '/') an absolute path-filename is returned." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
347 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
348 |
|sep s| |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
349 |
|
2906 | 350 |
(self ~~ ConcreteClass) ifTrue:[ |
351 |
^ ConcreteClass fromComponents:aCollectionOfDirectoryNames |
|
352 |
]. |
|
353 |
||
354 |
"/ fallBack - works on Unix & MSDOS |
|
355 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
356 |
sep := self separator asString. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
357 |
s := ''. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
358 |
aCollectionOfDirectoryNames keysAndValuesDo:[:index :component | |
2906 | 359 |
index == 1 ifTrue:[ |
360 |
(component ~= sep |
|
361 |
or:[aCollectionOfDirectoryNames size == 1]) ifTrue:[ |
|
362 |
s := s , component |
|
363 |
] |
|
364 |
] ifFalse:[ |
|
365 |
s := s , sep , component |
|
366 |
]. |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
367 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
368 |
^ self named:s |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
369 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
370 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
371 |
Filename fromComponents:#('/' 'foo' 'bar' 'baz') |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
372 |
Filename fromComponents:#('foo' 'bar' 'baz') |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
373 |
Filename fromComponents:#('/') |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
374 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
375 |
Filename fromComponents: |
2906 | 376 |
(Filename components:('.' asFilename pathName)) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
377 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
378 |
Filename fromComponents: |
2906 | 379 |
(Filename components:('.' asFilename name)) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
380 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
381 |
|
2906 | 382 |
"Modified: 8.9.1997 / 00:23:16 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
383 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
384 |
|
615 | 385 |
fromUser |
1225
b7def4d21cb8
use dialogs new requestFileName
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
386 |
"show a box to enter a filename. |
b7def4d21cb8
use dialogs new requestFileName
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
387 |
Return a filename instance or nil (if cancel was pressed)." |
615 | 388 |
|
389 |
|name| |
|
390 |
||
1225
b7def4d21cb8
use dialogs new requestFileName
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
391 |
name := Dialog requestFileName:'filename:' ifFail:nil. |
615 | 392 |
name notNil ifTrue:[^ self named:name]. |
393 |
^ nil |
|
394 |
||
395 |
" |
|
396 |
Filename fromUser |
|
397 |
" |
|
1225
b7def4d21cb8
use dialogs new requestFileName
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
398 |
|
b7def4d21cb8
use dialogs new requestFileName
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
399 |
"Modified: 19.4.1996 / 13:57:44 / cg" |
615 | 400 |
! |
401 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
402 |
homeDirectory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
403 |
"return your homeDirectory. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
404 |
Some OperatingSystems do not support this - on those, the defaultDirectory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
405 |
(which is the currentDirectory) is returned." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
406 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
407 |
|s| |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
408 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
409 |
s := OperatingSystem getHomeDirectory. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
410 |
s isNil ifTrue:[ |
2906 | 411 |
^ self defaultDirectory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
412 |
]. |
2906 | 413 |
^ self named:s |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
414 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
415 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
416 |
Filename homeDirectory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
417 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
418 |
|
2906 | 419 |
"Modified: 8.9.1997 / 00:25:23 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
420 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
421 |
|
615 | 422 |
named:aString |
423 |
"return a filename for a directory named aString. |
|
424 |
This is the same as 'aString asFilename'." |
|
425 |
||
2908 | 426 |
|cls| |
427 |
||
428 |
cls := self. |
|
429 |
cls == Filename ifTrue:[ |
|
430 |
cls := self concreteClass |
|
431 |
]. |
|
432 |
^ (cls basicNew) setName:aString |
|
615 | 433 |
|
434 |
" |
|
435 |
Filename named:'/tmp/fooBar' |
|
436 |
" |
|
2906 | 437 |
|
438 |
"Modified: 7.9.1997 / 23:30:06 / cg" |
|
615 | 439 |
! |
440 |
||
276 | 441 |
newTemporary |
325 | 442 |
"return a new unique filename - use this for temporary files. |
443 |
The filenames returned are '/tmp/stxtmp_xx_nn' where xx is our |
|
444 |
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
|
445 |
call to this method. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
446 |
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
|
447 |
its value defines the temp directory." |
276 | 448 |
|
2947 | 449 |
^ self newTemporaryIn:(self tempDirectory) pathName |
276 | 450 |
|
451 |
" |
|
422 | 452 |
Filename newTemporary |
1080 | 453 |
Filename newTemporary |
276 | 454 |
" |
422 | 455 |
|
456 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
1081
c2f1f8441663
renamed #temporaryDirectory to #tempDirectory
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
457 |
"Modified: 7.3.1996 / 14:51:33 / cg" |
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
458 |
! |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
459 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
460 |
newTemporaryIn:aDirectoryPrefix |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
461 |
"return a new unique filename - use this for temporary files. |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
462 |
The filenames returned are in aDirectoryPrefix and named 'stxtmp_xx_nn', |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
463 |
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
|
464 |
with every call to this method. |
2906 | 465 |
Notice: only a unique filename object is created and returned - no physical |
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
466 |
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
|
467 |
whatever to it in order to really create something). |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
468 |
See also: #newTemporary which looks for a good temp directory." |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
469 |
|
3059
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
470 |
|pid nameString fn| |
2906 | 471 |
|
472 |
(self ~~ ConcreteClass) ifTrue:[ |
|
473 |
^ ConcreteClass newTemporaryIn:aDirectoryPrefix |
|
474 |
]. |
|
475 |
||
3059
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
476 |
"/ care for existing leftOver tempFiles |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
477 |
"/ from a previous boot of the OS |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
478 |
"/ (i.e. my pid could be the same as when executed |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
479 |
"/ the last time before system reboot ...) |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
480 |
|
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
481 |
[fn isNil or:[fn exists]] whileTrue:[ |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
482 |
"/ although the above allows things to be redefined in concrete classes, |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
483 |
"/ the following should work on all systems ... |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
484 |
|
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
485 |
NextTempFilenameIndex isNil ifTrue:[ |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
486 |
NextTempFilenameIndex := 1. |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
487 |
]. |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
488 |
|
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
489 |
pid := OperatingSystem getProcessId printString. |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
490 |
nameString := (self tempFileNameTemplate) bindWith:pid with:(NextTempFilenameIndex printString). |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
491 |
NextTempFilenameIndex := NextTempFilenameIndex + 1. |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
492 |
|
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
493 |
(aDirectoryPrefix isNil or:[aDirectoryPrefix asString isEmpty]) ifFalse:[ |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
494 |
fn := aDirectoryPrefix asFilename construct:nameString |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
495 |
] ifTrue:[ |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
496 |
fn := self named:nameString |
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
497 |
] |
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
498 |
]. |
3059
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
499 |
^ fn |
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
500 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
501 |
"temp files in '/tmp': |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
502 |
|
1080 | 503 |
Filename newTemporary |
504 |
" |
|
505 |
||
506 |
"temp files somewhere |
|
507 |
(not recommended - use above since it can be controlled via shell variables): |
|
508 |
||
3752 | 509 |
UnixFilename newTemporaryIn:'/tmp' |
510 |
UnixFilename newTemporaryIn:'/tmp' |
|
511 |
UnixFilename newTemporaryIn:'/usr/tmp' |
|
512 |
UnixFilename newTemporaryIn:'/' |
|
483
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
513 |
" |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
514 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
515 |
"a local temp file: |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
516 |
|
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
517 |
Filename newTemporaryIn:'' |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
518 |
Filename newTemporaryIn:nil |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
519 |
Filename newTemporaryIn:'.' |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
520 |
Filename newTemporaryIn:('source' asFilename) |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
521 |
" |
f36d0167b819
newTemporyary and newTemporaryIn:
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
522 |
|
3059
3eb5132d391a
care for duplicate tempFile name.
Claus Gittinger <cg@exept.de>
parents:
3046
diff
changeset
|
523 |
"Modified: / 7.9.1995 / 10:48:31 / claus" |
3752 | 524 |
"Modified: / 11.8.1998 / 22:51:43 / cg" |
1080 | 525 |
! |
526 |
||
2922 | 527 |
rootDirectory |
528 |
"return a filename for the root directory" |
|
529 |
||
530 |
(self ~~ ConcreteClass) ifTrue:[ |
|
531 |
^ ConcreteClass rootDirectory |
|
532 |
]. |
|
533 |
||
534 |
"/ fallBack - works on Unix & MSDOS (but not on VMS) |
|
535 |
||
536 |
^ self named:(self separator asString) |
|
537 |
||
538 |
" |
|
539 |
Filename rootDirectory |
|
540 |
" |
|
541 |
||
542 |
"Modified: 8.9.1997 / 00:24:15 / cg" |
|
543 |
! |
|
544 |
||
3847
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
545 |
rootDirectoryOnVolume:aVolumeName |
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
546 |
"return a filename for the root directory on some volume" |
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
547 |
|
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
548 |
(self ~~ ConcreteClass) ifTrue:[ |
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
549 |
^ ConcreteClass rootDirectoryOnVolume:aVolumeName |
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
550 |
]. |
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
551 |
|
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
552 |
"/ fallBack - works on Unix (not on MSDOS or VMS) |
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
553 |
|
3871
745482fed59a
oops - rootDirectoryOnVolume: should fallBack to #rootDirectory.
Claus Gittinger <cg@exept.de>
parents:
3869
diff
changeset
|
554 |
^ self rootDirectory |
3847
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
555 |
|
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
556 |
" |
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
557 |
Filename rootDirectoryOnVolume:'/phys/idefix' |
3852 | 558 |
Filename rootDirectoryOnVolume:'d:' |
3847
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
559 |
" |
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
560 |
|
3871
745482fed59a
oops - rootDirectoryOnVolume: should fallBack to #rootDirectory.
Claus Gittinger <cg@exept.de>
parents:
3869
diff
changeset
|
561 |
"Modified: / 5.10.1998 / 12:45:39 / cg" |
3847
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
562 |
! |
91cd6bfb0296
added #rootDirectoryOnVolume:
Claus Gittinger <cg@exept.de>
parents:
3843
diff
changeset
|
563 |
|
1081
c2f1f8441663
renamed #temporaryDirectory to #tempDirectory
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
564 |
tempDirectory |
c2f1f8441663
renamed #temporaryDirectory to #tempDirectory
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
565 |
"return the temp directory as a filename. |
1968 | 566 |
If any of the environment variables STX_TMPDIR, ST_TMPDIR, |
567 |
TMPDIR or TEMPDIR is set, its value defines the name, |
|
568 |
otherwise, '/tmp' is used. (at least on unix ...). |
|
1081
c2f1f8441663
renamed #temporaryDirectory to #tempDirectory
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
569 |
|
c2f1f8441663
renamed #temporaryDirectory to #tempDirectory
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
570 |
Notice: do not hardcode '/tmp' into your programs - things may be |
2906 | 571 |
different on other OS's. Also, the user may want to set the |
572 |
TMPDIR environment variable to have her temp files somewhere else. |
|
573 |
(especially on SUNOS, the root partition is ALWAYS too small ..." |
|
1080 | 574 |
|
575 |
|tempDir| |
|
576 |
||
1969 | 577 |
#('STX_TMPDIR' 'ST_TMPDIR' 'TMPDIR' 'TEMPDIR' 'TEMP' 'TMP') do:[:envVar | |
2906 | 578 |
tempDir isNil ifTrue:[ |
579 |
tempDir := OperatingSystem getEnvironment:envVar. |
|
580 |
]. |
|
1968 | 581 |
]. |
1080 | 582 |
tempDir isNil ifTrue:[ |
2906 | 583 |
tempDir := self defaultTempDirectoryName |
1080 | 584 |
]. |
585 |
^ self named:tempDir |
|
586 |
||
587 |
" |
|
1081
c2f1f8441663
renamed #temporaryDirectory to #tempDirectory
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
588 |
Filename tempDirectory |
c2f1f8441663
renamed #temporaryDirectory to #tempDirectory
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
589 |
Filename tempDirectory pathName |
1080 | 590 |
" |
591 |
||
592 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
1081
c2f1f8441663
renamed #temporaryDirectory to #tempDirectory
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
593 |
"Created: 7.3.1996 / 14:51:18 / cg" |
2906 | 594 |
"Modified: 8.9.1997 / 00:08:11 / cg" |
1 | 595 |
! ! |
596 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
597 |
!Filename class methodsFor:'defaults'! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
598 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
599 |
concreteClass |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
600 |
"ST-80 compatibility: |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
601 |
in ST-80, different subclasses of Filename are used for different |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
602 |
OperatingSystems; concreteClass is supposed to return an appropriate class. |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
603 |
Since in ST/X, there is (currently) only one Filename class, return it here." |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
604 |
|
2906 | 605 |
^ ConcreteClass ? self |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
606 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
607 |
"Created: 14.2.1997 / 16:36:13 / cg" |
2906 | 608 |
"Modified: 7.9.1997 / 23:29:20 / cg" |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
609 |
! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
610 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
611 |
defaultClass |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
612 |
"ST-80 compatibility: |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
613 |
in ST-80, different subclasses of Filename are used for different |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
614 |
OperatingSystems; defaultClass is supposed to return an appropriate class. |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
615 |
Since in ST/X, there is (currently) only one Filename class, return it here." |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
616 |
|
2906 | 617 |
^ ConcreteClass |
618 |
||
619 |
"Modified: 8.9.1997 / 00:36:01 / cg" |
|
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
620 |
! ! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
621 |
|
2922 | 622 |
!Filename class methodsFor:'misc'! |
623 |
||
624 |
canonicalize:aPathString |
|
3077 | 625 |
"convert the argument, aPathString to a good format. |
626 |
This should eliminate useless directory components (i.e. '././') |
|
627 |
and useless tree walks (i.e. '../foo/..')." |
|
628 |
||
2922 | 629 |
^ aPathString |
630 |
||
3077 | 631 |
"Created: / 13.9.1997 / 10:50:01 / cg" |
632 |
"Modified: / 1.11.1997 / 12:44:57 / cg" |
|
633 |
! |
|
634 |
||
635 |
filterSeps:aFilenameString |
|
636 |
"ST80 compatibility: |
|
637 |
filter out (invalid) separators in aFilenameString. |
|
638 |
We recommend using #makeLegalFilename" |
|
639 |
||
3658 | 640 |
^ aFilenameString copyReplaceAll:(Character space) with:$_. |
3077 | 641 |
|
642 |
"Created: / 1.11.1997 / 12:39:50 / cg" |
|
3658 | 643 |
"Modified: / 18.7.1998 / 22:53:24 / cg" |
3077 | 644 |
! |
645 |
||
646 |
suggest:aFilenameString |
|
647 |
"return a fileNamestring based on the argument, |
|
648 |
which is legal on the current platform." |
|
649 |
||
650 |
^ self canonicalize:aFilenameString |
|
651 |
||
652 |
"Created: / 1.11.1997 / 12:42:39 / cg" |
|
2922 | 653 |
! ! |
654 |
||
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
655 |
!Filename class methodsFor:'queries'! |
2 | 656 |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
657 |
components:aString |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
658 |
"separate the pathName given by aString into |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
659 |
a collection containing the directory components and the files name as |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
660 |
the final component. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
661 |
If the argument names an absolute path, the first component will be the |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
662 |
name of the root directory (i.e. '/')." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
663 |
|
3852 | 664 |
|sep f vol rest components| |
2503 | 665 |
|
2906 | 666 |
(self ~~ ConcreteClass) ifTrue:[ |
667 |
^ ConcreteClass components:aString |
|
668 |
]. |
|
669 |
||
670 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
|
3852 | 671 |
"/ However, MSDOS drive-letters and network drives are |
672 |
"/ not correctly handled here. |
|
2906 | 673 |
|
2503 | 674 |
sep := self separator. |
3852 | 675 |
f := aString asFilename. |
676 |
vol := f volume. |
|
677 |
vol size ~~ 0 ifTrue:[ |
|
678 |
rest := f localPathName. |
|
679 |
] ifFalse:[ |
|
680 |
rest := aString |
|
681 |
]. |
|
682 |
||
683 |
components := rest asCollectionOfSubstringsSeparatedBy:sep. |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
684 |
components first isEmpty ifTrue:[ |
2906 | 685 |
components at:1 put:(sep asString) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
686 |
]. |
3852 | 687 |
|
688 |
"/ prepend volume to first component (the root directory) |
|
689 |
vol size ~~ 0 ifTrue:[ |
|
690 |
components at:1 put:(vol , (components at:1)). |
|
691 |
]. |
|
3373 | 692 |
components last isEmpty ifTrue:[ |
693 |
^ components copyWithoutLast:1 |
|
694 |
]. |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
695 |
^ components |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
696 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
697 |
" |
3373 | 698 |
Filename components:'/foo/bar/baz' |
3852 | 699 |
Filename components:'/' |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
700 |
Filename components:'foo/bar/baz' |
2503 | 701 |
Filename components:'foo/bar' |
702 |
Filename components:'foo' |
|
3852 | 703 |
Filename components:'/foo' |
704 |
||
705 |
Filename components:'\' |
|
706 |
Filename components:'\foo' |
|
707 |
Filename components:'\foo\' |
|
708 |
Filename components:'\foo\bar' |
|
709 |
Filename components:'\foo\bar\' |
|
710 |
Filename components:'c:' |
|
711 |
Filename components:'c:\' |
|
712 |
Filename components:'c:\foo' |
|
713 |
Filename components:'c:\foo\' |
|
714 |
Filename components:'c:\foo\bar' |
|
715 |
Filename components:'c:\foo\bar\' |
|
716 |
Filename components:'\\idefix' |
|
717 |
Filename components:'\\idefix\home' |
|
718 |
Filename components:'\\idefix\home\bar' |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
719 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
720 |
|
3852 | 721 |
"Modified: / 24.9.1998 / 19:10:52 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
722 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
723 |
|
2963 | 724 |
directorySuffix |
725 |
"Return the OS dependent directory suffix string, or nil if there is none. |
|
726 |
The default is nil here, redefined for VMS" |
|
727 |
||
728 |
(self ~~ ConcreteClass) ifTrue:[ |
|
729 |
^ ConcreteClass directorySuffix |
|
730 |
]. |
|
731 |
||
732 |
^ nil |
|
733 |
! |
|
734 |
||
1523 | 735 |
errorReporter |
736 |
"who knows the signals to report errors?" |
|
737 |
||
738 |
^ FileStream |
|
739 |
||
740 |
"Created: 2.7.1996 / 12:30:25 / stefan" |
|
741 |
! |
|
742 |
||
440 | 743 |
filenameCompletionFor:aString directory:inDirectory directoriesOnly:directoriesOnly filesOnly:filesOnly ifMultiple:aBlock |
744 |
"perform filename completion on aString in some directory; |
|
745 |
return the longest matching filename prefix as a string. |
|
1318 | 746 |
The boolean directoriesOnly and filesOnly control respectively, |
747 |
if only directories or only regular files are to be considered for completion. |
|
748 |
If multiple files match, the exception block aBlock is evaluated with a |
|
749 |
filename representing the directory (where the match was done) as argument. |
|
440 | 750 |
(this may be different from the inDirectory argument, if aString is absolute |
751 |
or starts with ../)" |
|
752 |
||
3854
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
753 |
|s f matchSet nMatch name words dir isAbsolute| |
440 | 754 |
|
2906 | 755 |
(self ~~ ConcreteClass) ifTrue:[ |
756 |
^ ConcreteClass |
|
757 |
filenameCompletionFor:aString |
|
758 |
directory:inDirectory |
|
759 |
directoriesOnly:directoriesOnly |
|
760 |
filesOnly:filesOnly |
|
761 |
ifMultiple:aBlock |
|
762 |
]. |
|
763 |
||
764 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
|
765 |
||
440 | 766 |
s := aString. |
767 |
" |
|
768 |
find the last word ... |
|
769 |
" |
|
770 |
words := s asCollectionOfWords. |
|
771 |
words size == 0 ifTrue:[ |
|
2906 | 772 |
aBlock value:'.' asFilename. |
773 |
^ '' |
|
440 | 774 |
]. |
775 |
||
776 |
f := words last asFilename. |
|
3854
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
777 |
isAbsolute := f isAbsolute. |
440 | 778 |
|
779 |
matchSet := f filenameCompletionIn:inDirectory. |
|
780 |
||
781 |
dir := f directory. |
|
782 |
||
783 |
directoriesOnly ifTrue:[ |
|
2906 | 784 |
matchSet := matchSet select:[:aFilename | |
3854
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
785 |
|f| |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
786 |
|
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
787 |
isAbsolute ifTrue:[ |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
788 |
f := aFilename asFilename |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
789 |
] ifFalse:[ |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
790 |
f := (dir construct:aFilename). |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
791 |
]. |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
792 |
f isDirectory |
2906 | 793 |
]. |
440 | 794 |
] ifFalse:[ |
2906 | 795 |
filesOnly ifTrue:[ |
796 |
matchSet := matchSet select:[:aFilename | |
|
3854
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
797 |
|f| |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
798 |
|
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
799 |
isAbsolute ifTrue:[ |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
800 |
f := aFilename asFilename |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
801 |
] ifFalse:[ |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
802 |
f := (dir construct:aFilename). |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
803 |
]. |
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
804 |
f isDirectory not |
2906 | 805 |
]. |
806 |
] |
|
440 | 807 |
]. |
808 |
||
809 |
(nMatch := matchSet size) ~~ 1 ifTrue:[ |
|
2906 | 810 |
" |
811 |
more than one possible completion - |
|
812 |
" |
|
813 |
aBlock value:f |
|
440 | 814 |
]. |
815 |
" |
|
816 |
even with more than one possible completion, |
|
817 |
f's name is now the common prefix |
|
818 |
" |
|
819 |
name := f asString. |
|
820 |
nMatch == 1 ifTrue:[ |
|
2906 | 821 |
" |
822 |
exactly one possible completion - |
|
823 |
" |
|
3752 | 824 |
"/ f := dir construct:matchSet first. |
825 |
false "directoriesOnly" ifFalse:[ |
|
2906 | 826 |
f isDirectory ifTrue:[ |
827 |
(name endsWith:(Filename separator)) ifFalse:[ |
|
3504 | 828 |
name := name , (Filename separator) |
2906 | 829 |
]. |
830 |
]. |
|
831 |
] |
|
440 | 832 |
]. |
833 |
||
834 |
" |
|
835 |
construct new contents, by taking |
|
836 |
last words completion |
|
837 |
" |
|
838 |
s := ''. |
|
839 |
1 to:(words size - 1) do:[:idx | |
|
2906 | 840 |
s := s , (words at:idx) , ' ' |
440 | 841 |
]. |
842 |
s := s , name. |
|
843 |
||
844 |
"/ special: if there was no change, and the string represented |
|
845 |
"/ is a directories name, add a directory separator |
|
3503
0734014ecea8
apped '/' if there is exactly one match and its a directory
Claus Gittinger <cg@exept.de>
parents:
3373
diff
changeset
|
846 |
((nMatch == 1) or:[s = aString]) ifTrue:[ |
2906 | 847 |
(s endsWith:Filename separator) ifFalse:[ |
848 |
s asFilename isDirectory ifTrue:[ |
|
849 |
^ s , Filename separator asString |
|
850 |
] |
|
3503
0734014ecea8
apped '/' if there is exactly one match and its a directory
Claus Gittinger <cg@exept.de>
parents:
3373
diff
changeset
|
851 |
]. |
440 | 852 |
]. |
853 |
||
854 |
^ s |
|
1318 | 855 |
|
3854
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
856 |
"Modified: / 24.9.1998 / 22:10:34 / cg" |
615 | 857 |
! |
858 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
859 |
filesMatching:aPattern |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
860 |
"return a collection of strings, representing the names |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
861 |
of files matching aPattern. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
862 |
If aPattern contains a directory path, files are tried there; |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
863 |
otherwise, files from the currentDirectory are tried. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
864 |
The returned strings are the expanded names, in the same form |
2550 | 865 |
as given in pattern. |
866 |
The pattern should be a simple pattern." |
|
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
867 |
|
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
868 |
|basePattern dir d files| |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
869 |
|
2906 | 870 |
(self ~~ ConcreteClass) ifTrue:[ |
871 |
^ ConcreteClass filesMatching:aPattern |
|
872 |
]. |
|
873 |
||
874 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
|
875 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
876 |
dir := aPattern asFilename directoryName. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
877 |
basePattern := aPattern asFilename baseName. |
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
878 |
d := dir asFilename. |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
879 |
files := dir asFilename filesMatchingWithoutDotDirs:basePattern. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
880 |
dir = '.' ifTrue:[^ files]. |
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
881 |
^ files collect:[:base | d constructString:base]. |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
882 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
883 |
" |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
884 |
Filename filesMatching:'*' |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
885 |
Filename filesMatching:'/*' |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
886 |
Filename filesMatching:'/usr/local/*' |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
887 |
" |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
888 |
|
2906 | 889 |
"Modified: 8.9.1997 / 00:32:31 / cg" |
615 | 890 |
! |
891 |
||
2903 | 892 |
isBadCharacter:aCharacter |
893 |
"return true, if aCharacter is unallowed in a filename." |
|
894 |
||
895 |
|ascii| |
|
896 |
||
2906 | 897 |
(self ~~ ConcreteClass) ifTrue:[ |
898 |
^ ConcreteClass isBadCharacter:aCharacter |
|
899 |
]. |
|
900 |
||
2903 | 901 |
ascii := aCharacter asciiValue. |
902 |
ascii < 32 ifTrue:[ |
|
2906 | 903 |
^ true "/ a control character |
2903 | 904 |
]. |
905 |
ascii == 16rFF ifTrue:[ |
|
2906 | 906 |
^ true "/ delete character |
2903 | 907 |
]. |
908 |
^ false |
|
2906 | 909 |
|
910 |
"Modified: 8.9.1997 / 00:32:59 / cg" |
|
2903 | 911 |
! |
912 |
||
913 |
isCaseSensitive |
|
914 |
"return true, if filenames are case sensitive. |
|
915 |
We ask the OS about this, to be independent here." |
|
916 |
||
2906 | 917 |
(self ~~ ConcreteClass) ifTrue:[ |
918 |
^ ConcreteClass isCaseSensitive |
|
919 |
]. |
|
920 |
||
2903 | 921 |
^ OperatingSystem caseSensitiveFilenames |
2906 | 922 |
|
923 |
"Modified: 8.9.1997 / 00:33:32 / cg" |
|
2903 | 924 |
! |
925 |
||
615 | 926 |
localNameStringFrom:aString |
927 |
"ST-80 compatibility. |
|
928 |
what does this do ? (used in FileNavigator-goody). |
|
2922 | 929 |
GUESS: |
930 |
does it strip off any volume characters and make a path relative ?" |
|
931 |
||
932 |
|sep| |
|
615 | 933 |
|
2906 | 934 |
(self ~~ ConcreteClass) ifTrue:[ |
935 |
^ ConcreteClass localNameStringFrom:aString |
|
936 |
]. |
|
937 |
||
2922 | 938 |
sep := self separator asString. |
939 |
(aString startsWith:sep) ifTrue:[ |
|
940 |
^ aString copyFrom:sep size + 1 |
|
615 | 941 |
]. |
942 |
^ aString |
|
943 |
||
944 |
"Modified: 7.9.1995 / 10:44:56 / claus" |
|
2906 | 945 |
"Modified: 8.9.1997 / 00:33:51 / cg" |
615 | 946 |
! |
947 |
||
2908 | 948 |
maxComponentLength |
949 |
"return the maximum number of characters a filename component may |
|
950 |
be in size. This depends on the OperatingSystem." |
|
951 |
||
952 |
(self ~~ ConcreteClass) ifTrue:[ |
|
953 |
^ ConcreteClass maxComponentLength |
|
954 |
]. |
|
955 |
^ OperatingSystem maxFileNameLength |
|
956 |
! |
|
957 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
958 |
maxLength |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
959 |
"return the maximum number of characters a filename may be in size. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
960 |
This depends on the OperatingSystem." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
961 |
|
2908 | 962 |
(self ~~ ConcreteClass) ifTrue:[ |
963 |
^ ConcreteClass maxLength |
|
964 |
]. |
|
965 |
^ OperatingSystem maxPathLength |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
966 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
967 |
"Created: 29.2.1996 / 20:57:11 / cg" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
968 |
"Modified: 29.2.1996 / 20:57:46 / cg" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
969 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
970 |
|
3171 | 971 |
nullFilename |
972 |
"Return the OS dependent filename for /dev/null, or nil if there is none. |
|
973 |
The default is nil here" |
|
974 |
||
975 |
(self ~~ ConcreteClass) ifTrue:[ |
|
976 |
^ ConcreteClass nullFilename |
|
977 |
]. |
|
978 |
||
979 |
^ nil |
|
980 |
||
981 |
"Created: / 12.1.1998 / 12:15:30 / stefan" |
|
982 |
! |
|
983 |
||
615 | 984 |
parentDirectoryName |
985 |
"return the name used for the parent directory. |
|
986 |
This is '..' for unix and dos-like systems. |
|
987 |
(there may be more in the future." |
|
988 |
||
2906 | 989 |
(self ~~ ConcreteClass) ifTrue:[ |
990 |
^ ConcreteClass parentDirectoryName |
|
991 |
]. |
|
992 |
||
993 |
^ OperatingSystem parentDirectoryName |
|
994 |
||
995 |
" |
|
996 |
Filename parentDirectoryName |
|
997 |
" |
|
998 |
||
999 |
"Modified: 8.9.1997 / 00:34:39 / cg" |
|
615 | 1000 |
! |
1001 |
||
1002 |
separator |
|
1003 |
"return the file/directory separator. |
|
2906 | 1004 |
This is to be redefined in concrete classes; |
1005 |
the following default usually leads to a flat view of |
|
1006 |
the fileSystem (huh - BS2000 ?)" |
|
1007 |
||
1008 |
(self ~~ ConcreteClass) ifTrue:[ |
|
1009 |
^ ConcreteClass separator |
|
1010 |
]. |
|
1011 |
^ $_ |
|
615 | 1012 |
|
1013 |
" |
|
1014 |
Filename separator |
|
1015 |
" |
|
2906 | 1016 |
|
1017 |
"Modified: 8.9.1997 / 00:20:28 / cg" |
|
615 | 1018 |
! |
1019 |
||
1020 |
suffixSeparator |
|
1021 |
"return the filename suffix separator. |
|
1022 |
Usually, this is $. for unix-like and msdos systems |
|
1318 | 1023 |
(there is currently no known system, where this differs)" |
615 | 1024 |
|
1025 |
^ $. |
|
1026 |
||
1027 |
" |
|
1028 |
Filename suffixSeparator |
|
1029 |
" |
|
1030 |
||
1031 |
"Modified: 7.9.1995 / 11:10:43 / claus" |
|
1318 | 1032 |
"Modified: 30.4.1996 / 12:14:25 / cg" |
615 | 1033 |
! |
1034 |
||
2906 | 1035 |
tempFileNameTemplate |
1036 |
"return a template for temporary files. |
|
1037 |
This is expanded with the current processID and a sequenceNumber |
|
1038 |
to generate a unique filename." |
|
1039 |
||
1040 |
(self ~~ ConcreteClass) ifTrue:[ |
|
1041 |
^ ConcreteClass tempFileNameTemplate |
|
1042 |
]. |
|
1043 |
||
1044 |
^ 'stxtmp_%1_%2' |
|
1045 |
||
1046 |
"Created: 8.9.1997 / 00:01:46 / cg" |
|
1047 |
"Modified: 8.9.1997 / 00:35:02 / cg" |
|
1048 |
! |
|
1049 |
||
615 | 1050 |
volumes |
1051 |
"ST-80 compatibility. |
|
2896 | 1052 |
GUESS: does it return the available drives on MSDOS systems ? |
1053 |
Q: what does this do on Unix systems ? (used in FileNavigator-goody)." |
|
1054 |
||
2906 | 1055 |
(self ~~ ConcreteClass) ifTrue:[ |
1056 |
^ ConcreteClass volumes |
|
1057 |
]. |
|
1058 |
||
2896 | 1059 |
^ OperatingSystem getDriveList |
615 | 1060 |
|
1061 |
"Modified: 7.9.1995 / 10:45:25 / claus" |
|
2906 | 1062 |
"Modified: 8.9.1997 / 00:35:19 / cg" |
615 | 1063 |
! ! |
1064 |
||
1065 |
!Filename methodsFor:'comparing'! |
|
1066 |
||
1067 |
= aFilename |
|
1068 |
"return true, if the argument represents the same filename" |
|
1069 |
||
1070 |
|str| |
|
1071 |
||
1072 |
self species == aFilename species ifTrue:[ |
|
1073 |
str := aFilename asString. |
|
1074 |
self class isCaseSensitive ifTrue:[ |
|
1075 |
^ nameString = str |
|
1076 |
]. |
|
1077 |
^ nameString sameAs:str |
|
1078 |
]. |
|
1079 |
^ false |
|
1080 |
! |
|
1081 |
||
1082 |
hash |
|
1083 |
"return an integer useful as a hash-key" |
|
1084 |
||
1085 |
^ nameString hash |
|
3868 | 1086 |
! |
1087 |
||
1088 |
sameContentsAs:aFilename |
|
1089 |
"return true if the file represented by the receiver has the |
|
1090 |
same contents as the file represented by the argument, aFilename. |
|
1091 |
This compares the files actual contents; not the filenames." |
|
1092 |
||
1093 |
|s1 s2 buffer1 buffer2 rslt n| |
|
1094 |
||
1095 |
buffer1 := ByteArray new:8192. |
|
1096 |
buffer2 := ByteArray new:8192. |
|
1097 |
||
1098 |
s1 := self readStream. |
|
1099 |
s1 isNil ifTrue:[ |
|
1100 |
^ self error:('cannot open %1 for reading' bindWith:nameString) |
|
1101 |
]. |
|
1102 |
s2 := aFilename asFilename readStream. |
|
1103 |
s2 isNil ifTrue:[ |
|
1104 |
^ self error:('cannot open %1 for reading' bindWith:aFilename asFilename name) |
|
1105 |
]. |
|
3869
6d7dca488a41
read binary, in #sameContentsAs:
Claus Gittinger <cg@exept.de>
parents:
3868
diff
changeset
|
1106 |
s1 binary. |
6d7dca488a41
read binary, in #sameContentsAs:
Claus Gittinger <cg@exept.de>
parents:
3868
diff
changeset
|
1107 |
s2 binary. |
3868 | 1108 |
|
1109 |
[s1 atEnd] whileFalse:[ |
|
1110 |
n := s1 nextBytes:8192 into:buffer1 startingAt:1. |
|
1111 |
n == 0 ifTrue:[ |
|
1112 |
rslt := s2 atEnd. |
|
1113 |
s1 close. s2 close. |
|
1114 |
^ rslt |
|
1115 |
]. |
|
1116 |
(s2 nextBytes:n into:buffer2 startingAt:1) ~~ n ifTrue:[ |
|
1117 |
"/ aFilename shorter |
|
1118 |
s1 close. s2 close. |
|
1119 |
^ false |
|
1120 |
]. |
|
1121 |
buffer1 ~= buffer2 ifTrue:[ |
|
1122 |
s1 close. s2 close. |
|
1123 |
^ false |
|
1124 |
] |
|
1125 |
]. |
|
1126 |
rslt := s2 atEnd. |
|
1127 |
s1 close. s2 close. |
|
1128 |
^ rslt |
|
1129 |
||
1130 |
" |
|
1131 |
'Make.proto' asFilename sameContentsAs:'Makefile' |
|
1132 |
" |
|
615 | 1133 |
! ! |
1134 |
||
1135 |
!Filename methodsFor:'converting'! |
|
1136 |
||
1137 |
asAbsoluteFilename |
|
1138 |
"return the receiver converted to a filename with |
|
1139 |
an absolute pathname." |
|
1140 |
||
1141 |
^ self pathName asFilename |
|
1142 |
! |
|
1143 |
||
1144 |
asFilename |
|
1970 | 1145 |
"return the receiver converted to a filename; here, thats the receiver itself." |
615 | 1146 |
|
1147 |
"Thats pretty easy here :-)" |
|
1148 |
^ self |
|
1970 | 1149 |
|
1150 |
"Modified: 12.11.1996 / 12:40:03 / cg" |
|
615 | 1151 |
! |
1152 |
||
1153 |
asString |
|
1154 |
"return the receiver converted to a string" |
|
1155 |
||
1156 |
^ nameString |
|
1157 |
! |
|
1158 |
||
1159 |
makeLegalFilename |
|
1970 | 1160 |
"convert the receivers name to be a legal filename. |
1161 |
This removes/replaces invalid characters and/or compresses |
|
1162 |
the name as required by the OS. |
|
615 | 1163 |
The implementation may change in the future to be more |
1164 |
OS specific." |
|
1165 |
||
1166 |
" |
|
1167 |
actually, in Unix spaces are allowed - but it makes life |
|
1168 |
so hard; therefore, replace them by underscores ... |
|
1169 |
" |
|
3658 | 1170 |
(nameString includes:Character space) ifTrue:[ |
1171 |
nameString := nameString copyReplaceAll:(Character space) with:$_. |
|
1172 |
]. |
|
615 | 1173 |
" |
1174 |
need more - especially on SYS5.3 type systems, |
|
1175 |
we may want to contract the fileName to 14 characters. |
|
1176 |
" |
|
1177 |
^ self |
|
1178 |
||
1179 |
" |
|
1180 |
'hello world' asFilename makeLegalFilename |
|
1181 |
" |
|
1970 | 1182 |
|
3658 | 1183 |
"Modified: / 20.7.1998 / 13:16:51 / cg" |
2707
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
1184 |
! |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
1185 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
1186 |
withEncoding:encodingSymbol |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
1187 |
"dummy for now - for ST80 compatibility" |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
1188 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
1189 |
^ self |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
1190 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
1191 |
"Created: 20.6.1997 / 17:01:28 / cg" |
2 | 1192 |
! ! |
1193 |
||
542 | 1194 |
!Filename methodsFor:'error handling'! |
1195 |
||
615 | 1196 |
accessDeniedError:filename |
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1197 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1198 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1199 |
"report an error that access to some file was denied" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1200 |
|
615 | 1201 |
^ OperatingSystem accessDeniedErrorSignal |
542 | 1202 |
raiseRequestWith:filename |
615 | 1203 |
errorString:('access denied: ' , filename asString) |
1204 |
! |
|
1205 |
||
1206 |
fileCreationError:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1207 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1208 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1209 |
"report an error that some file could not be created" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1210 |
|
615 | 1211 |
^ OperatingSystem accessDeniedErrorSignal |
1212 |
raiseRequestWith:filename |
|
1213 |
errorString:('cannot create/write file: ' , filename asString) |
|
542 | 1214 |
! |
1215 |
||
1216 |
fileNotFoundError:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1217 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1218 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1219 |
"report an error that some file was not found" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1220 |
|
542 | 1221 |
^ OperatingSystem fileNotFoundErrorSignal |
1222 |
raiseRequestWith:filename |
|
1223 |
errorString:('file not found: ' , filename asString) |
|
1224 |
! |
|
1225 |
||
1226 |
removeError:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1227 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1228 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1229 |
"report an error that some file could not be removed" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1230 |
|
542 | 1231 |
^ OperatingSystem accessDeniedErrorSignal |
1232 |
raiseRequestWith:filename |
|
1233 |
errorString:('cannot remove: ' , filename asString) |
|
615 | 1234 |
! |
1235 |
||
1236 |
reportError:string with:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1237 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1238 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1239 |
"report an error" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1240 |
|
615 | 1241 |
^ OperatingSystem errorSignal |
1242 |
raiseRequestWith:filename |
|
1243 |
errorString:string |
|
1244 |
! ! |
|
1245 |
||
1246 |
!Filename methodsFor:'file access'! |
|
1247 |
||
3015 | 1248 |
appendStream |
1249 |
"return a stream for appending to the file represented by the receiver. |
|
1250 |
If the file does not already exist, it is created. |
|
1251 |
Same as #appendingWriteStream for ST-80 compatibility." |
|
1252 |
||
1253 |
^ self appendingWriteStream |
|
1254 |
! |
|
1255 |
||
615 | 1256 |
appendingWriteStream |
1257 |
"return a stream for appending to the file represented by the receiver. |
|
1258 |
If the file does not already exist, it is created." |
|
1259 |
||
2947 | 1260 |
^ FileStream appendingOldFileNamed:(self osNameForAccess) |
615 | 1261 |
! |
1262 |
||
1263 |
newReadWriteStream |
|
1264 |
"return a stream for read/write the file represented by the receiver. |
|
1265 |
If the file does not already exist, it is created." |
|
1266 |
||
2947 | 1267 |
^ FileStream newFileNamed:(self osNameForAccess) |
615 | 1268 |
! |
1269 |
||
1270 |
readStream |
|
1271 |
"return a stream for reading from the file represented by the receiver. |
|
1272 |
If the file does not already exist, nil is returned." |
|
1273 |
||
2947 | 1274 |
^ FileStream readonlyFileNamed:(self osNameForAccess) |
615 | 1275 |
|
1276 |
" |
|
1277 |
'/tmp/foo' asFilename readStream |
|
1278 |
" |
|
1279 |
! |
|
1280 |
||
1281 |
readWriteStream |
|
1282 |
"return a stream for read/write the file represented by the receiver. |
|
1283 |
If the file does not already exist, nil is returned." |
|
1284 |
||
2947 | 1285 |
^ FileStream oldFileNamed:(self osNameForAccess) |
615 | 1286 |
! |
1287 |
||
1288 |
writeStream |
|
1289 |
"return a stream for writing to the file represented by the receiver. |
|
1290 |
If the file does not already exist, it is created." |
|
1291 |
||
2947 | 1292 |
^ FileStream newFileForWritingNamed:(self osNameForAccess) |
615 | 1293 |
|
1294 |
" |
|
1295 |
'/tmp/foo' asFilename writeStream |
|
1296 |
" |
|
1297 |
! ! |
|
1298 |
||
1299 |
!Filename methodsFor:'file operations'! |
|
1300 |
||
1301 |
addAccessRights:aCollection |
|
1302 |
"add the access rights as specified in aCollection for the file represented |
|
1303 |
by the receiver. The argument must be a collection of symbols, |
|
1304 |
such as #readUser, #writeGroup etc." |
|
1305 |
||
2922 | 1306 |
|access osName| |
1307 |
||
2947 | 1308 |
osName := self osNameForFile. |
2922 | 1309 |
access := OperatingSystem accessModeOf:osName. |
615 | 1310 |
aCollection do:[:accessSymbol | |
1311 |
access := access bitOr:(OperatingSystem accessMaskFor:accessSymbol). |
|
1312 |
]. |
|
2922 | 1313 |
(OperatingSystem changeAccessModeOf:osName to:access) ifFalse:[ |
615 | 1314 |
^ self accessDeniedError:self |
1315 |
] |
|
1316 |
||
1317 |
" |
|
1318 |
'foo' asFilename writeStream close. |
|
1319 |
'foo' asFilename addAccessRights:#(readUser readGroup readOthers). |
|
1320 |
'foo' asFilename addAccessRights:#(writeUser writeGroup writeOthers). |
|
1321 |
'foo' asFilename addAccessRights:#(executeUser executeGroup executeOthers). |
|
1322 |
" |
|
1323 |
! |
|
1324 |
||
2982 | 1325 |
basicMakeDirectory |
1326 |
"create a directory with the receivers name. |
|
1327 |
Return true if successful, false if not." |
|
1328 |
||
1329 |
^ OperatingSystem createDirectory:(self osNameForDirectory) |
|
1330 |
! |
|
1331 |
||
615 | 1332 |
copyTo:newName |
1333 |
"copy the file - the argument must be convertable to a filename. |
|
671 | 1334 |
Return true if successful, false if not." |
615 | 1335 |
|
1336 |
|inStream outStream buffer bufferSize count newFile| |
|
1337 |
||
1338 |
bufferSize := 8 * 1024. |
|
1339 |
buffer := ByteArray new:bufferSize. |
|
1340 |
inStream := self readStream. |
|
1341 |
inStream isNil ifTrue:[ |
|
1342 |
^ self fileNotFoundError:self |
|
1343 |
]. |
|
1344 |
||
1345 |
outStream := (newFile := newName asFilename) writeStream. |
|
1346 |
outStream isNil ifTrue:[ |
|
1347 |
^ self fileCreationError:newFile |
|
1348 |
]. |
|
1349 |
||
1350 |
[inStream atEnd] whileFalse:[ |
|
1351 |
count := inStream nextBytes:bufferSize into:buffer. |
|
1352 |
(outStream nextPutBytes:count from:buffer) ~= count ifTrue:[ |
|
1353 |
^ self fileCreationError:newFile |
|
1354 |
] |
|
1355 |
]. |
|
1356 |
outStream close. |
|
1357 |
inStream close. |
|
1358 |
||
1359 |
" |
|
1360 |
'Makefile' asFilename copyTo:'Makefile.foo' |
|
1361 |
'smalltalk' asFilename copyTo:'/dev/null' |
|
1362 |
" |
|
1363 |
! |
|
1364 |
||
1365 |
delete |
|
1366 |
"remove the file - same as remove, for ST-80 compatibility" |
|
1367 |
||
1368 |
self remove |
|
1369 |
! |
|
1370 |
||
1371 |
makeDirectory |
|
1372 |
"create a directory with the receivers name. |
|
671 | 1373 |
Return true if successful, false if not." |
615 | 1374 |
|
2982 | 1375 |
(self basicMakeDirectory) ifFalse:[ |
1376 |
"/ |
|
1377 |
"/ could have existed before ... |
|
1378 |
"/ |
|
2629 | 1379 |
(self exists and:[self isDirectory]) ifFalse:[ |
2982 | 1380 |
self fileCreationError:self. |
1381 |
^ false |
|
2629 | 1382 |
] |
2982 | 1383 |
]. |
1384 |
^ true |
|
1970 | 1385 |
|
1386 |
"Modified: 12.11.1996 / 12:25:22 / cg" |
|
615 | 1387 |
! |
1388 |
||
844 | 1389 |
makeExecutable |
1390 |
"make the file executable - you must have permission to do so. |
|
1391 |
For directories, execution means: 'allow changing into it'" |
|
1392 |
||
1393 |
^ self addAccessRights:#(executeUser) |
|
1394 |
||
1395 |
"Created: 9.1.1996 / 15:32:47 / cg" |
|
1396 |
! |
|
1397 |
||
1398 |
makeExecutableForAll |
|
1399 |
"make the file executable for all - you must have permission to do so. |
|
1400 |
For directories, execution means: 'allow changing into it'" |
|
1401 |
||
1402 |
^ self addAccessRights:#(executeUser executeGroup executeOthers) |
|
1403 |
||
1404 |
"Created: 9.1.1996 / 15:32:28 / cg" |
|
1405 |
! |
|
1406 |
||
615 | 1407 |
makeReadable |
1408 |
"make the file readable for the owner - you must have permission to do so." |
|
1409 |
||
1410 |
^ self addAccessRights:#(readUser) |
|
1411 |
! |
|
1412 |
||
1413 |
makeReadableForAll |
|
1414 |
"make the file readable for all - you must have permission to do so." |
|
1415 |
||
1416 |
^ self addAccessRights:#(readUser readGroup readOthers) |
|
1417 |
! |
|
1418 |
||
1419 |
makeUnwritable |
|
1420 |
"make the file unwritable for all - you must have permission to do so." |
|
1421 |
||
1422 |
^ self removeAccessRights:#(writeUser writeGroup writeOthers) |
|
1423 |
! |
|
1424 |
||
1425 |
makeWritable |
|
1426 |
"make the file writableable for all - you must have permission to do so." |
|
1427 |
||
1428 |
^ self addAccessRights:#(writeUser) |
|
1429 |
! |
|
1430 |
||
1431 |
makeWritableForAll |
|
1432 |
"make the file writable for all - you must have permission to do so." |
|
1433 |
||
1434 |
^ self addAccessRights:#(writeUser writeGroup writeOthers) |
|
1435 |
! |
|
1436 |
||
1437 |
moveTo:newName |
|
1438 |
"copy the file represented by the receiver, then delete it. |
|
1439 |
This is different to renaming in case of cross device moves. |
|
671 | 1440 |
Raise an error if not successful." |
615 | 1441 |
|
1442 |
self copyTo:newName. |
|
1443 |
self remove |
|
1444 |
! |
|
1445 |
||
659 | 1446 |
recursiveMakeDirectory |
1447 |
"create a directory with the receivers name and all required intermediate |
|
1448 |
directories. |
|
671 | 1449 |
Raise an error if not successful." |
659 | 1450 |
|
2922 | 1451 |
(OperatingSystem recursiveCreateDirectory:(self osNameForDirectory)) ifFalse:[ |
671 | 1452 |
^ self fileCreationError:self |
659 | 1453 |
] |
1454 |
||
1455 |
"Created: 27.11.1995 / 23:36:40 / cg" |
|
1456 |
! |
|
1457 |
||
615 | 1458 |
recursiveRemove |
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1459 |
"if I represent a regular file, remove it. |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1460 |
Otherwise, remove the directory and all of its subfiles/subdirectories. |
671 | 1461 |
Raise an error if not successful." |
615 | 1462 |
|
1463 |
|ok| |
|
1464 |
||
3302 | 1465 |
"/ typically, an 'rm -rf' is faster and removes better; |
1466 |
"/ however, if the fork fails, fallBack doing a manual |
|
1467 |
"/ directory walk. |
|
1468 |
||
1469 |
ok := OperatingSystem recursiveRemoveDirectory:(self osNameForDirectory). |
|
1470 |
ok ifFalse:[ |
|
1471 |
self recursiveRemoveWithoutOSCommand |
|
1472 |
]. |
|
1473 |
||
1474 |
" |
|
1475 |
'foo' asFilename makeDirectory. |
|
1476 |
'foo/bar' asFilename writeStream close. |
|
1477 |
('foo' asFilename remove) ifFalse:[ |
|
1478 |
Transcript showCR:'could not remove foo' |
|
1479 |
] |
|
1480 |
" |
|
1481 |
" |
|
1482 |
'foo' asFilename makeDirectory. |
|
1483 |
'foo/bar' asFilename writeStream close. |
|
1484 |
('foo' asFilename recursiveRemove) ifFalse:[ |
|
1485 |
Transcript showCR:'could not remove foo' |
|
1486 |
] |
|
1487 |
" |
|
1488 |
||
1489 |
"Created: / 14.11.1995 / 11:19:29 / cg" |
|
1490 |
"Modified: / 25.2.1998 / 19:51:34 / cg" |
|
1491 |
! |
|
1492 |
||
1493 |
recursiveRemoveWithoutOSCommand |
|
1494 |
"if I represent a regular file, remove it. |
|
1495 |
Otherwise, remove the directory and all of its subfiles/subdirectories. |
|
1496 |
Raise an error if not successful. |
|
1497 |
This one walks down the directory hierarchy, not using any OS |
|
1498 |
command to do the remove." |
|
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1499 |
|
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1500 |
self isDirectory ifTrue:[ |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1501 |
self directoryContents do:[:aFilenameString | |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1502 |
|f| |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1503 |
|
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1504 |
f := self construct:aFilenameString. |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1505 |
f isDirectory ifTrue:[ |
3302 | 1506 |
f recursiveRemoveWithoutOSCommand |
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1507 |
] ifFalse:[ |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1508 |
f remove |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1509 |
]. |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1510 |
] |
615 | 1511 |
]. |
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1512 |
self remove |
615 | 1513 |
|
1514 |
" |
|
1515 |
'foo' asFilename makeDirectory. |
|
1516 |
'foo/bar' asFilename writeStream close. |
|
1517 |
('foo' asFilename remove) ifFalse:[ |
|
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1518 |
Transcript showCR:'could not remove foo' |
615 | 1519 |
] |
1520 |
" |
|
1521 |
" |
|
1522 |
'foo' asFilename makeDirectory. |
|
1523 |
'foo/bar' asFilename writeStream close. |
|
1524 |
('foo' asFilename recursiveRemove) ifFalse:[ |
|
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
1525 |
Transcript showCR:'could not remove foo' |
615 | 1526 |
] |
1527 |
" |
|
1528 |
||
3302 | 1529 |
"Created: / 25.2.1998 / 19:50:40 / cg" |
1530 |
"Modified: / 25.2.1998 / 19:52:08 / cg" |
|
615 | 1531 |
! |
1532 |
||
1533 |
remove |
|
845 | 1534 |
"remove the file/directory. |
672 | 1535 |
Raise an error if not successful. |
845 | 1536 |
Use #recursiveRemove in order to (recursively) remove non empty directories." |
615 | 1537 |
|
1538 |
|ok| |
|
1539 |
||
1540 |
self exists ifFalse:[ ^ self]. |
|
3113
43e75ed892cf
Removing a symlink to a directory must call #removeFile:.
Stefan Vogel <sv@exept.de>
parents:
3077
diff
changeset
|
1541 |
(self isSymbolicLink not and:[self isDirectory]) ifTrue:[ |
43e75ed892cf
Removing a symlink to a directory must call #removeFile:.
Stefan Vogel <sv@exept.de>
parents:
3077
diff
changeset
|
1542 |
ok := OperatingSystem removeDirectory:(self osNameForFile) |
615 | 1543 |
] ifFalse:[ |
3113
43e75ed892cf
Removing a symlink to a directory must call #removeFile:.
Stefan Vogel <sv@exept.de>
parents:
3077
diff
changeset
|
1544 |
ok := OperatingSystem removeFile:(self osNameForFile) |
615 | 1545 |
]. |
1546 |
ok ifFalse:[ |
|
3113
43e75ed892cf
Removing a symlink to a directory must call #removeFile:.
Stefan Vogel <sv@exept.de>
parents:
3077
diff
changeset
|
1547 |
self removeError:self |
615 | 1548 |
]. |
1549 |
||
1550 |
" |
|
1551 |
(FileStream newFileNamed:'foo') close. |
|
1552 |
'foo' asFilename remove |
|
1553 |
" |
|
1554 |
||
1555 |
" |
|
1556 |
'foo' asFilename makeDirectory. |
|
1557 |
'foo/bar' asFilename writeStream close. |
|
1558 |
('foo' asFilename remove) ifFalse:[ |
|
3113
43e75ed892cf
Removing a symlink to a directory must call #removeFile:.
Stefan Vogel <sv@exept.de>
parents:
3077
diff
changeset
|
1559 |
Transcript showCR:'could not remove foo' |
615 | 1560 |
] |
1561 |
" |
|
1562 |
||
3113
43e75ed892cf
Removing a symlink to a directory must call #removeFile:.
Stefan Vogel <sv@exept.de>
parents:
3077
diff
changeset
|
1563 |
"Modified: / 10.1.1996 / 18:44:50 / cg" |
43e75ed892cf
Removing a symlink to a directory must call #removeFile:.
Stefan Vogel <sv@exept.de>
parents:
3077
diff
changeset
|
1564 |
"Modified: / 20.11.1997 / 17:40:22 / stefan" |
615 | 1565 |
! |
1566 |
||
1567 |
removeAccessRights:aCollection |
|
1568 |
"remove the access rights as specified in aCollection for the file represented |
|
1569 |
by the receiver. The argument must be a collection of symbols, |
|
671 | 1570 |
such as #readUser, #writeGroup etc. |
1571 |
Raise an error if not successful." |
|
615 | 1572 |
|
2922 | 1573 |
|access osName| |
1574 |
||
2947 | 1575 |
osName := self osNameForFile. |
2922 | 1576 |
access := OperatingSystem accessModeOf:osName. |
615 | 1577 |
aCollection do:[:accessSymbol | |
1578 |
access := access bitAnd:(OperatingSystem accessMaskFor:accessSymbol) bitInvert. |
|
1579 |
]. |
|
2922 | 1580 |
(OperatingSystem changeAccessModeOf:osName to:access) ifFalse:[ |
615 | 1581 |
^ self accessDeniedError:self |
1582 |
]. |
|
1583 |
||
1584 |
" |
|
1585 |
'foo' asFilename writeStream close. |
|
1586 |
'foo' asFilename removeAccessRights:#(readUser readGroup readOthers). |
|
1587 |
'foo' asFilename removeAccessRights:#(writeUser writeGroup writeOthers). |
|
1588 |
'foo' asFilename removeAccessRights:#(executeUser executeGroup executeOthers). |
|
1589 |
" |
|
1590 |
! |
|
1591 |
||
1592 |
renameTo:newName |
|
671 | 1593 |
"rename the file - the argument must be convertable to a String. |
1594 |
Raise an error if not successful." |
|
615 | 1595 |
|
2922 | 1596 |
(OperatingSystem |
1597 |
renameFile:(self osNameForFile) |
|
1598 |
to:(newName asFilename osNameForFile) |
|
1599 |
) ifFalse:[ |
|
615 | 1600 |
self exists ifFalse:[ |
1601 |
^ self fileNotFoundError:self |
|
1602 |
]. |
|
1603 |
^ self accessDeniedError:newName asFilename. |
|
1604 |
]. |
|
1605 |
||
1606 |
" |
|
1607 |
'/tmp/foo' asFilename renameTo:'/tmp/bar' |
|
1608 |
" |
|
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1609 |
! |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1610 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1611 |
truncateTo:newSize |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1612 |
"change the files size. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1613 |
This may not be supported on all operating systems" |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1614 |
|
2922 | 1615 |
(OperatingSystem truncateFile:(self osNameForFile) to:newSize) ifFalse:[ |
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
1616 |
^ self reportError:'unsupported operation' with:self |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1617 |
] |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1618 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1619 |
" |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1620 |
|s| |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1621 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1622 |
s := 'test' asFilename writeStream. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1623 |
s next:1000 put:$1. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1624 |
s close. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1625 |
('test' asFilename fileSize) printNL. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1626 |
'test' asFilename truncateTo:100. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1627 |
('test' asFilename fileSize) printNL. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
1628 |
" |
615 | 1629 |
! ! |
1630 |
||
1631 |
!Filename methodsFor:'file queries'! |
|
1632 |
||
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1633 |
accessTime |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1634 |
"return a timeStamp containing the files last access time." |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1635 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1636 |
| i | |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1637 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1638 |
(i := self info) isNil ifTrue:[^ nil]. |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1639 |
^ i accessed |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1640 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1641 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1642 |
Filename currentDirectory accessTime |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1643 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1644 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1645 |
"Created: / 9.7.1996 / 10:19:15 / cg" |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1646 |
"Modified: / 26.9.1997 / 13:05:51 / stefan" |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1647 |
"Modified: / 17.8.1998 / 10:23:44 / cg" |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1648 |
! |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1649 |
|
615 | 1650 |
dates |
1651 |
"return the files modification and access times as an object (currently a dictionary) |
|
1652 |
that responds to the at: message with arguments |
|
1653 |
#modified, #accessed or #statusChanged." |
|
1654 |
||
2922 | 1655 |
|info dates osName| |
1656 |
||
2947 | 1657 |
osName := self osNameForAccess. |
2922 | 1658 |
info := OperatingSystem infoOf:osName. |
615 | 1659 |
info isNil ifTrue:[ |
2922 | 1660 |
info := OperatingSystem linkInfoOf:osName. |
2629 | 1661 |
info isNil ifTrue:[ |
1662 |
^ nil |
|
1663 |
] |
|
615 | 1664 |
]. |
1665 |
dates := IdentityDictionary new. |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1666 |
dates at:#modified put:(info modified). |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1667 |
dates at:#accessed put:(info accessed). |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1668 |
dates at:#statusChanged put:(info statusChanged). |
615 | 1669 |
^ dates |
1670 |
||
1671 |
" |
|
1672 |
Filename currentDirectory dates |
|
1673 |
'../regression' asFilename dates |
|
1674 |
" |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1675 |
|
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1676 |
"Modified: 1.11.1996 / 20:19:24 / cg" |
615 | 1677 |
! |
1678 |
||
1679 |
fileSize |
|
1680 |
"return the size of the file in bytes" |
|
1681 |
||
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1682 |
|i| |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1683 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1684 |
(i := self info) isNil ifTrue:[^ nil]. |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1685 |
^ i size |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1686 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1687 |
"Modified: / 17.8.1998 / 10:23:46 / cg" |
615 | 1688 |
! |
1689 |
||
1690 |
fileType |
|
1691 |
"this returns a string describing the type of contents of |
|
1692 |
the file. This is done using the unix 'file' command, |
|
1693 |
(which usually is configurable by /etc/magic). |
|
3665 | 1694 |
On non-unix systems, this may simply return 'file', |
2922 | 1695 |
not knowning about the contents. |
1696 |
Warning: |
|
1697 |
Since the returned string differs among systems (and language settings), |
|
3665 | 1698 |
it is only useful for user-information; |
1699 |
NOT as a tag to be used by a program." |
|
1700 |
||
1701 |
|type buffer s n suffix idx baseNm| |
|
1702 |
||
1703 |
"/ since we cannot depend on a 'file' command being available, |
|
1704 |
"/ do the most obvious ones here. |
|
1705 |
"/ (also useful since the 'file' command takes some time, and the code |
|
1706 |
"/ below is faster for common things like directories) |
|
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
1707 |
|
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
1708 |
self isSymbolicLink ifTrue:[ |
2906 | 1709 |
^ 'symbolic link to ' , (self linkInfo path) |
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
1710 |
]. |
2573 | 1711 |
self isDirectory ifTrue:[ |
2906 | 1712 |
self isReadable ifFalse:[^ 'directory, unreadable']. |
1713 |
self isExecutable ifFalse:[^ 'directory, locked']. |
|
1714 |
^ 'directory' |
|
2573 | 1715 |
]. |
3665 | 1716 |
(type := self type) == #characterSpecial ifTrue:[ |
1717 |
^ 'character device special file' |
|
1718 |
]. |
|
1719 |
type == #blockSpecial ifTrue:[ |
|
1720 |
^ 'block device special file' |
|
1721 |
]. |
|
1722 |
type == #socket ifTrue:[ |
|
1723 |
^ 'socket' |
|
1724 |
]. |
|
1725 |
||
1602 | 1726 |
self isReadable ifFalse:[^ 'unreadable']. |
1612
730781a80e2a
inline detect empty and HTML documents
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
1727 |
self fileSize == 0 ifTrue:[^ 'empty']. |
1602 | 1728 |
|
2922 | 1729 |
suffix := self suffix asLowercase. |
1730 |
baseNm := self withoutSuffix baseName asLowercase. |
|
1731 |
||
1732 |
((#('st' 'rc' 'chg' 'htm' 'html' 'ps') includes:suffix) |
|
1733 |
or:[#('makefile') includes:baseNm]) ifTrue:[ |
|
1734 |
||
1735 |
buffer := String new:2024. |
|
1736 |
s := self readStream. |
|
1737 |
s notNil ifTrue:[ |
|
1738 |
n := s nextBytes:buffer size into:buffer. |
|
1739 |
s close. |
|
1740 |
||
1741 |
(suffix = 'st') ifTrue:[ |
|
2906 | 1742 |
(buffer findString:'subclass:') ~~ 0 ifTrue:[ |
1743 |
^ 'smalltalk source' |
|
1744 |
]. |
|
1745 |
(buffer findString:'methodsFor:') ~~ 0 ifTrue:[ |
|
1746 |
^ 'smalltalk source' |
|
1747 |
]. |
|
1748 |
]. |
|
1749 |
||
1750 |
(buffer findString:'methodsFor:') ~~ 0 ifTrue:[ |
|
1751 |
^ 'smalltalk changes / method source' |
|
1752 |
]. |
|
1753 |
||
1754 |
(suffix = 'rc') ifTrue:[ |
|
1755 |
(buffer findString:'ST/X startup') ~~ 0 ifTrue:[ |
|
1756 |
^ 'smalltalk startup script' |
|
1757 |
]. |
|
1758 |
]. |
|
2922 | 1759 |
|
2906 | 1760 |
(suffix = 'htm' or:[suffix = 'html']) ifTrue:[ |
1761 |
(idx := buffer findString:'<H') ~~ 0 ifTrue:[ |
|
1762 |
((buffer continuesWith:'<HEAD' startingAt:idx) |
|
1763 |
or:[(buffer continuesWith:'<HTML' startingAt:idx) |
|
1764 |
or:[(buffer continuesWith:'<H1' startingAt:idx) |
|
1765 |
or:[(buffer continuesWith:'<H2' startingAt:idx) |
|
1766 |
or:[(buffer continuesWith:'<H3' startingAt:idx) |
|
1767 |
or:[(buffer continuesWith:'<H4' startingAt:idx) |
|
1768 |
or:[(buffer continuesWith:'<H5' startingAt:idx) |
|
1769 |
or:[(buffer continuesWith:'<H6' startingAt:idx)]]]]]]]) |
|
1770 |
ifTrue:[ |
|
1771 |
^ 'HTML document text' |
|
1772 |
] |
|
1773 |
]. |
|
1774 |
]. |
|
1614
4e1a64b19247
inline detect postscript documents
Claus Gittinger <cg@exept.de>
parents:
1612
diff
changeset
|
1775 |
|
2906 | 1776 |
(suffix = 'ps') ifTrue:[ |
1777 |
(buffer findString:'%!!PS-Adobe') ~~ 0 ifTrue:[ |
|
1778 |
^ 'PostScript document' |
|
1779 |
]. |
|
1780 |
]. |
|
1781 |
||
1782 |
(baseNm = 'makefile') ifTrue:[ |
|
1783 |
(buffer startsWith:'#') ifTrue:[ |
|
1784 |
^ 'make rules' |
|
1785 |
] |
|
3665 | 1786 |
] |
2906 | 1787 |
] |
1602 | 1788 |
]. |
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
1789 |
|
2906 | 1790 |
^ 'file' |
615 | 1791 |
|
1792 |
" |
|
1793 |
'Makefile' asFilename fileType |
|
1794 |
'.' asFilename fileType |
|
3665 | 1795 |
'/dev/null' asFilename fileType |
1796 |
'/tmp/.X11-unix/X0' asFilename fileType |
|
615 | 1797 |
'smalltalk.rc' asFilename fileType |
1798 |
'bitmaps/SBrowser.xbm' asFilename fileType |
|
1799 |
" |
|
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
1800 |
|
3665 | 1801 |
"Modified: / 21.7.1998 / 11:25:56 / cg" |
615 | 1802 |
! |
1803 |
||
2836 | 1804 |
id |
1805 |
"return the files/directories file-id (inode number)" |
|
1806 |
||
2947 | 1807 |
^ OperatingSystem idOf:(self osNameForAccess) |
2836 | 1808 |
|
1809 |
" |
|
1810 |
Filename currentDirectory id |
|
1811 |
" |
|
1812 |
||
1813 |
"Modified: 9.7.1996 / 10:19:27 / cg" |
|
1814 |
"Created: 5.8.1997 / 19:26:01 / cg" |
|
1815 |
! |
|
1816 |
||
615 | 1817 |
info |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1818 |
"return some object filled with the files info; |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1819 |
the info (for which corresponding access methods are understood by |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1820 |
the returned object) is: |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1821 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1822 |
type - a symbol giving the files fileType |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1823 |
mode - numeric access mode |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1824 |
uid - owners user id |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1825 |
gid - owners group id |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1826 |
size - files size |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1827 |
id - files number (i.e. inode number) |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1828 |
accessed - last access time (as osTime-stamp) |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1829 |
modified - last modification time (as osTime-stamp) |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1830 |
statusChanged - last staus change (as osTime-stamp) |
615 | 1831 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1832 |
Some of the fields may be returned as nil on systems which do not provide |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1833 |
all of the information. |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1834 |
The minimum returned info (i.e. on all OS's) will consist of at least: |
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1835 |
modified |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1836 |
size |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1837 |
type |
615 | 1838 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1839 |
Dont expect things like uid/gid/mode to be non-nil; write your application |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1840 |
to either handle nil values, |
615 | 1841 |
or (better) use one of isXXXX query methods. (Be prepared for DOS ...) |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1842 |
(i.e. instead of: |
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1843 |
someFilename type == #directory |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1844 |
use |
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1845 |
someFilename isDirectory |
615 | 1846 |
" |
1847 |
||
2947 | 1848 |
^ OperatingSystem infoOf:(self osNameForAccess) |
615 | 1849 |
|
1850 |
" |
|
1851 |
Filename currentDirectory info |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1852 |
'/dev/null' asFilename info |
615 | 1853 |
'Make.proto' asFilename info |
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1854 |
'source/Point.st' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1855 |
'source/Point.st' asFilename linkInfo |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1856 |
'../../libbasic/Point.st' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1857 |
'.' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1858 |
'..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1859 |
'..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1860 |
'..\..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1861 |
'..\..\..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1862 |
'c:\' asFilename info |
615 | 1863 |
" |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1864 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
1865 |
"Modified: / 17.8.1998 / 10:24:10 / cg" |
615 | 1866 |
! |
1867 |
||
1868 |
linkInfo |
|
1869 |
"return the files info if its a symbolic link; nil otherwise. |
|
1870 |
On OS's which do not support symbolic links, nil is always returned. |
|
1871 |
The information is the same as returned by #info, except that if the |
|
1872 |
receiver represents a symbolic link, the links information |
|
1873 |
is returned |
|
1874 |
(while in this case, #info returns the info of the target file, |
|
1875 |
which is accessed via the symbolic link). |
|
1876 |
||
1877 |
In addition to the normal entries, Unix returns an additional entry: |
|
2629 | 1878 |
path -> the target files pathname |
615 | 1879 |
|
1880 |
See the comment in #info for more details." |
|
1881 |
||
2947 | 1882 |
^ OperatingSystem linkInfoOf:(self osNameForAccess) |
615 | 1883 |
|
1884 |
" |
|
1885 |
Filename currentDirectory linkInfo |
|
1886 |
'/dev/null' asFilename linkInfo |
|
1887 |
'Make.proto' asFilename linkInfo |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1859
diff
changeset
|
1888 |
'Make.proto' asFilename linkInfo path |
615 | 1889 |
'source/Point.st' asFilename linkInfo |
1890 |
'../../libbasic/Point.st' asFilename linkInfo |
|
1891 |
" |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1859
diff
changeset
|
1892 |
|
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1859
diff
changeset
|
1893 |
"Modified: 1.11.1996 / 20:49:09 / cg" |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1894 |
! |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1895 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1896 |
modificationTime |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1897 |
"return a timeStamp containing the files modification time." |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1898 |
|
3763
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
1899 |
|i| |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
1900 |
|
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
1901 |
(i := self info) isNil ifTrue:[^ nil]. "/ non-existing |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
1902 |
^ i modified |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1903 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1904 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1905 |
Filename currentDirectory modificationTime |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1906 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1907 |
|
3763
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
1908 |
"Created: / 9.7.1996 / 10:18:59 / cg" |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
1909 |
"Modified: / 26.9.1997 / 13:05:39 / stefan" |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
1910 |
"Modified: / 14.8.1998 / 17:42:50 / cg" |
2836 | 1911 |
! |
1912 |
||
1913 |
type |
|
1914 |
"return the symbolic type of the file" |
|
1915 |
||
2947 | 1916 |
^ OperatingSystem typeOf:(self osNameForAccess) |
2836 | 1917 |
|
1918 |
" |
|
1919 |
Filename currentDirectory type |
|
1920 |
" |
|
1921 |
||
1922 |
"Modified: 9.7.1996 / 10:19:27 / cg" |
|
1923 |
"Created: 5.8.1997 / 19:31:26 / cg" |
|
615 | 1924 |
! ! |
1925 |
||
1926 |
!Filename methodsFor:'file utilities'! |
|
1927 |
||
1928 |
edit |
|
1929 |
"start an editView on the file represented by the receiver" |
|
1930 |
||
1931 |
EditTextView openOn:self asString |
|
1932 |
||
1933 |
" |
|
1934 |
'smalltalk.rc' asFilename edit |
|
1935 |
" |
|
1936 |
! |
|
1937 |
||
1938 |
fileIn |
|
1939 |
"load smalltalk code from the file" |
|
1940 |
||
1941 |
^ self readStream fileIn |
|
542 | 1942 |
! ! |
1943 |
||
2 | 1944 |
!Filename methodsFor:'instance creation'! |
1945 |
||
615 | 1946 |
construct:subname |
1947 |
"taking the receiver as a directory name, construct a new |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1948 |
filename for an entry within this directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1949 |
(i.e. for a file or a subdirectory in that directory). |
2922 | 1950 |
The argument may not specify an absolute path name. |
1951 |
Please do not use this to create filenames with suffixes, |
|
1952 |
since some systems require special naming conventions. |
|
1953 |
See also: #withSuffix: (which is different, but often needed)." |
|
615 | 1954 |
|
2903 | 1955 |
^ self class named:(self constructString:subname) |
615 | 1956 |
|
1957 |
" |
|
1958 |
'/tmp' asFilename construct:'foo' |
|
1959 |
'/' asFilename construct:'foo' |
|
1960 |
'/usr/tmp' asFilename construct:'foo' |
|
1961 |
'/foo/bar' asFilename construct:'baz' |
|
2922 | 1962 |
|
1963 |
Bad example; works on UNIX, but may not on others: |
|
1964 |
'foo/bar.baz' construct:'.suff' |
|
615 | 1965 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1966 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1967 |
"Modified: 29.2.1996 / 20:55:06 / cg" |
2911 | 1968 |
! |
1969 |
||
2922 | 1970 |
constructDirectory:subname |
1971 |
"same as #construct: on most systems. |
|
1972 |
(may allow different/relaxed name syntax of the argument on some systems)" |
|
1973 |
||
1974 |
^ self class named:(self constructDirectoryString:subname) |
|
1975 |
! |
|
1976 |
||
1977 |
constructDirectoryString:subName |
|
1978 |
"same as #constructString: on most systems. |
|
1979 |
(may allow different/relaxed name syntax of the argument on some systems)" |
|
1980 |
||
1981 |
^ self constructString:subName |
|
1982 |
! |
|
1983 |
||
1984 |
constructString:subName |
|
2911 | 1985 |
"taking the receiver as a directory name, construct a new |
1986 |
filename-string for an entry within this directory |
|
2922 | 1987 |
(i.e. for a file or a subdirectory in that directory). |
2960 | 1988 |
The argument may not specify an absolute path name. |
1989 |
The code below works for UNIX & MSDOS; |
|
1990 |
other filename classes (i.e. VMS) may want to redefine this method." |
|
1991 |
||
1992 |
|sepString sub| |
|
1993 |
||
1994 |
sub := subName asString. |
|
2911 | 1995 |
sepString := self class separator asString. |
1996 |
nameString = sepString ifTrue:[ |
|
1997 |
"I am the root" |
|
2960 | 1998 |
^ sepString , sub |
2911 | 1999 |
]. |
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2000 |
(nameString endsWith:sepString) ifTrue:[ |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2001 |
^ nameString , sub |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2002 |
]. |
2960 | 2003 |
^ nameString , sepString , sub |
2911 | 2004 |
|
2005 |
" |
|
2006 |
'/tmp' asFilename constructString:'foo' |
|
2007 |
'/' asFilename constructString:'foo' |
|
2008 |
'/usr/tmp' asFilename constructString:'foo' |
|
2009 |
'/foo/bar' asFilename constructString:'baz' |
|
2010 |
" |
|
2011 |
||
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2012 |
"Modified: / 7.9.1995 / 10:15:22 / claus" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2013 |
"Created: / 9.9.1997 / 08:57:08 / cg" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2014 |
"Modified: / 20.1.1998 / 15:58:23 / md" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2015 |
"Modified: / 27.7.1998 / 19:47:51 / cg" |
2944
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2016 |
! |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2017 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2018 |
filenameFor:fileName |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2019 |
"taking the receiver as a directory name, construct a new |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2020 |
filename for an entry within this directory |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2021 |
(i.e. for a file or a subdirectory in that directory). |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2022 |
If the argument specifies an absolute path name, the argument is returned." |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2023 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2024 |
|f| |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2025 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2026 |
f := fileName asFilename. |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2027 |
f isAbsolute ifTrue:[^ f]. |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2028 |
^ (self construct:fileName) |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2029 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2030 |
" |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2031 |
'/tmp' asFilename filenameFor:'foo' |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2032 |
'/tmp' asFilename filenameFor:'/foo' |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2033 |
" |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2034 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2035 |
"Created: 18.9.1997 / 14:34:14 / stefan" |
2 | 2036 |
! ! |
2037 |
||
195 | 2038 |
!Filename methodsFor:'misc'! |
2039 |
||
2040 |
, aString |
|
2041 |
"this allows filenames to understand how names are concatenated. |
|
308 | 2042 |
Returns a string consisting of the receivers name, concatenated |
195 | 2043 |
by aString. Notice this is NOT the same as construct:, which inserts |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2044 |
a directory delimiter and returns a new fileName instance. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2045 |
See also: #withSuffix: which is new and better." |
195 | 2046 |
|
2906 | 2047 |
self obsoleteMethodWarning:'use #construct:'. |
308 | 2048 |
^ (nameString , aString asString) |
195 | 2049 |
|
2050 |
" |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2051 |
'Makefile' asFilename , '.bak' |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2052 |
('Makefile' asFilename , '.bak') asFilename |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2053 |
'Makefile' asFilename withSuffix:'bak' |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2054 |
'Makefile' asFilename construct:'.bak' |
195 | 2055 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2056 |
|
2906 | 2057 |
"Modified: 7.9.1997 / 23:45:36 / cg" |
195 | 2058 |
! ! |
2059 |
||
615 | 2060 |
!Filename methodsFor:'printing & storing'! |
174 | 2061 |
|
615 | 2062 |
printOn:aStream |
2063 |
"append a printed representation of the receiver to aStream." |
|
174 | 2064 |
|
2906 | 2065 |
aStream nextPutAll:(self class name). |
2066 |
aStream nextPutAll:'('''. |
|
615 | 2067 |
nameString printOn:aStream. |
2068 |
aStream nextPutAll:''')' |
|
2906 | 2069 |
|
2070 |
"Modified: 7.9.1997 / 23:46:20 / cg" |
|
1 | 2071 |
! |
2072 |
||
615 | 2073 |
storeOn:aStream |
2074 |
"append a printed representation of the receiver to aStream, |
|
2075 |
which allows reconstructing it via readFrom:" |
|
328 | 2076 |
|
615 | 2077 |
aStream nextPut:$(. |
2078 |
nameString storeOn:aStream. |
|
2079 |
aStream nextPutAll:' asFilename)' |
|
1 | 2080 |
! ! |
2081 |
||
202 | 2082 |
!Filename methodsFor:'private accessing'! |
1 | 2083 |
|
68 | 2084 |
setName:aString |
38 | 2085 |
"set the filename" |
2086 |
||
3666 | 2087 |
nameString := self nameWithSpecialExpansions:aString. |
2088 |
||
2089 |
"Modified: / 21.7.1998 / 10:44:18 / cg" |
|
1 | 2090 |
! ! |
2091 |
||
2 | 2092 |
!Filename methodsFor:'queries'! |
2093 |
||
615 | 2094 |
canBeWritten |
2095 |
"same as isWritable - for ST-80 compatibility" |
|
328 | 2096 |
|
615 | 2097 |
^ self isWritable |
92 | 2098 |
|
328 | 2099 |
" |
615 | 2100 |
'/foo/bar' asFilename canBeWritten |
2101 |
'/tmp' asFilename canBeWritten |
|
2102 |
'Makefile' asFilename canBeWritten |
|
328 | 2103 |
" |
2104 |
! |
|
2105 |
||
68 | 2106 |
exists |
92 | 2107 |
"return true, if such a file exists." |
68 | 2108 |
|
2947 | 2109 |
^ OperatingSystem isValidPath:(self osNameForAccess) |
68 | 2110 |
|
85 | 2111 |
" |
92 | 2112 |
'/foo/bar' asFilename exists |
2113 |
'/tmp' asFilename exists |
|
2114 |
'Makefile' asFilename exists |
|
85 | 2115 |
" |
77 | 2116 |
! |
2117 |
||
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2118 |
filesMatching:aPattern |
2550 | 2119 |
"given the receiver, representing a directory; |
2120 |
return a collection of files matching a pattern. |
|
2121 |
The pattern may be a simple matchPattern, or a set of |
|
2122 |
multiple patterns separated by semicolons." |
|
2123 |
||
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2124 |
|matchers notCaseSensitive| |
2550 | 2125 |
|
2126 |
matchers := aPattern asCollectionOfSubstringsSeparatedBy:$;. |
|
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2127 |
notCaseSensitive := self class isCaseSensitive not. |
2550 | 2128 |
^ self directoryContents |
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2129 |
select:[:name | |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2130 |
(matchers detect:[:p | p match:name ignoreCase:notCaseSensitive] ifNone:0) ~~ 0 |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2131 |
] |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2132 |
|
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2133 |
" |
2550 | 2134 |
'/etc' asFilename filesMatching:'a*;c*' |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2135 |
" |
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2136 |
|
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2137 |
"Created: / 15.4.1997 / 15:40:02 / cg" |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2138 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
2550 | 2139 |
! |
2140 |
||
2141 |
filesMatchingWithoutDotDirs:aPattern |
|
2142 |
"given the receiver, representing a directory; |
|
2143 |
return a collection of files matching a pattern. |
|
2144 |
Exclude '.' and '..' from the returned list. |
|
2145 |
The pattern may be a simple matchPattern, or a set of |
|
2146 |
multiple patterns separated by semicolons." |
|
2147 |
||
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2148 |
|matchers notCaseSensitive| |
2550 | 2149 |
|
2150 |
matchers := aPattern asCollectionOfSubstringsSeparatedBy:$;. |
|
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2151 |
notCaseSensitive := self class isCaseSensitive not. |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2152 |
|
2550 | 2153 |
^ self directoryContents |
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2154 |
select:[:name | |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2155 |
name ~= '.' |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2156 |
and:[name ~= '..' |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2157 |
and:[(matchers detect:[:p | p match:name ignoreCase:notCaseSensitive] ifNone:0) ~~ 0]] |
2550 | 2158 |
] |
2159 |
||
2160 |
" |
|
2161 |
Filename currentDirectory filesMatching:'M*' |
|
2162 |
'/etc' asFilename filesMatching:'[a-z]*' |
|
2163 |
'../../libbasic' asFilename filesMatching:'[A-D]*.st' |
|
2164 |
" |
|
2165 |
||
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2166 |
"Created: / 15.4.1997 / 12:52:10 / cg" |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
2167 |
"Modified: / 3.8.1998 / 21:22:30 / cg" |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2168 |
! |
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
2169 |
|
615 | 2170 |
isAbsolute |
2171 |
"return true, if the receiver represents an absolute pathname |
|
2172 |
(in contrast to one relative to the current directory)." |
|
356 | 2173 |
|
2629 | 2174 |
(nameString startsWith:self class separator) ifTrue:[^ true]. |
2175 |
^ self isVolumeAbsolute |
|
328 | 2176 |
|
2177 |
" |
|
615 | 2178 |
'/foo/bar' asFilename isAbsolute |
2179 |
'..' asFilename isAbsolute |
|
2180 |
'..' asAbsoluteFilename isAbsolute |
|
2181 |
'source/SBrowser.st' asFilename isAbsolute |
|
2182 |
" |
|
2183 |
! |
|
2184 |
||
2185 |
isDirectory |
|
2186 |
"return true, if the receiver represents an existing, |
|
2187 |
readable directories pathname." |
|
2188 |
||
2947 | 2189 |
^ OperatingSystem isDirectory:(self osNameForAccess) |
615 | 2190 |
|
2191 |
" |
|
2192 |
'/foo/bar' asFilename isDirectory |
|
2193 |
'/tmp' asFilename isDirectory |
|
2194 |
'Makefile' asFilename isDirectory |
|
3843 | 2195 |
'c:\' asFilename isDirectory |
2196 |
'd:\' asFilename isDirectory |
|
615 | 2197 |
" |
3843 | 2198 |
|
2199 |
"Modified: / 21.9.1998 / 15:53:10 / cg" |
|
615 | 2200 |
! |
2201 |
||
2202 |
isExecutable |
|
2203 |
"return true, if such a file exists and is executable (by Unix's definition). |
|
2204 |
For directories, true is returned if the directory can be entered. |
|
2205 |
See isExecutableProgram for a related check." |
|
2206 |
||
2947 | 2207 |
^ OperatingSystem isExecutable:(self osNameForAccess) |
615 | 2208 |
|
2209 |
" |
|
2210 |
'/foo/bar' asFilename isExecutable |
|
2211 |
'/tmp' asFilename isExecutable |
|
2212 |
'Makefile' asFilename isExecutable |
|
2213 |
'/bin/ls' asFilename isExecutable |
|
356 | 2214 |
" |
2215 |
! |
|
2216 |
||
615 | 2217 |
isExecutableProgram |
2218 |
"return true, if such a file exists and is an executable program. |
|
2219 |
(i.e. for directories, false is returned.)" |
|
356 | 2220 |
|
2922 | 2221 |
|osName| |
2222 |
||
2947 | 2223 |
osName := self osNameForAccess. |
2922 | 2224 |
^ (OperatingSystem isExecutable:osName) |
2225 |
and:[(OperatingSystem isDirectory:osName) not] |
|
356 | 2226 |
|
2227 |
" |
|
615 | 2228 |
'/tmp' asFilename isExecutable |
2229 |
'/bin/ls' asFilename isExecutable |
|
2230 |
'/tmp' asFilename isExecutableProgram |
|
2231 |
'/bin/ls' asFilename isExecutableProgram |
|
2232 |
" |
|
2233 |
! |
|
2234 |
||
2922 | 2235 |
isExplicitRelative |
2236 |
"return true, if this name is an explicit relative name |
|
2237 |
(i.e. starts with './' or '../', to avoid path-prepending)" |
|
2238 |
||
2239 |
^ false |
|
2240 |
! |
|
2241 |
||
2242 |
isHidden |
|
2243 |
"return true, if the receiver represents a hidden file. |
|
2244 |
The definitions of hidden files depends on the OS used; |
|
2245 |
on UNIX, a name starting with a period is considered hidden; |
|
2246 |
on MSDOS, the files hidden attribute is used. |
|
2247 |
VMS has no concept of hidden files." |
|
2248 |
||
2249 |
^ false |
|
2250 |
! |
|
2251 |
||
2944
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2252 |
isImplicit |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2253 |
"return true, if the receiver represents a builtin file. |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2254 |
The definitions of builtin files depends on the OS used; |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2255 |
on UNIX, '.' and '..' are builtin names." |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2256 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2257 |
^ false |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2258 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2259 |
"Created: 18.9.1997 / 18:04:51 / stefan" |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2260 |
! |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
2261 |
|
615 | 2262 |
isReadable |
2263 |
"return true, if such a file exists and is readable." |
|
2264 |
||
2947 | 2265 |
^ OperatingSystem isReadable:(self osNameForFile) |
615 | 2266 |
|
2267 |
" |
|
2268 |
'/foo/bar' asFilename isReadable |
|
2269 |
'/tmp' asFilename isReadable |
|
2270 |
'Makefile' asFilename isReadable |
|
328 | 2271 |
" |
2272 |
! |
|
2273 |
||
615 | 2274 |
isRelative |
2275 |
"return true, if this name is interpreted relative to some |
|
2276 |
directory (opposite of absolute)" |
|
328 | 2277 |
|
615 | 2278 |
^ self isAbsolute not |
2175 | 2279 |
|
2280 |
" |
|
2281 |
'./foo/bar' asFilename isRelative |
|
2282 |
'../../foo/bar' asFilename isRelative |
|
2283 |
'/foo/bar' asFilename isRelative |
|
2284 |
'bar' asFilename isRelative |
|
2285 |
" |
|
2286 |
||
2287 |
"Modified: 16.1.1997 / 01:19:14 / cg" |
|
615 | 2288 |
! |
328 | 2289 |
|
3045 | 2290 |
isRootDirectory |
3046 | 2291 |
"return true, if I represent the root directory |
2292 |
(i.e. I have no parentDir)" |
|
2293 |
||
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2294 |
"/ mhmh - should we use: |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2295 |
"/ |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2296 |
"/ parentDir := self construct:'..'. |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2297 |
"/ (parentDir exists |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2298 |
"/ and:[parentDir isDirectory |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2299 |
"/ and:[parentDir id ~= self id]]) ifTrue:[ |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2300 |
"/ ^ false |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2301 |
"/ ]. |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2302 |
"/ ^ true |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2303 |
"/ |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2304 |
|
3046 | 2305 |
^ self pathName = Filename rootDirectory pathName |
2306 |
||
2307 |
"Modified: 23.10.1997 / 00:38:35 / cg" |
|
3045 | 2308 |
! |
2309 |
||
615 | 2310 |
isSymbolicLink |
2311 |
"return true, if the file represented by the receiver is a symbolic |
|
2312 |
link. Notice that not all OS's support symbolic links; those that do |
|
2313 |
not will always return false." |
|
2314 |
||
2947 | 2315 |
^ OperatingSystem isSymbolicLink:(self osNameForFile) |
328 | 2316 |
|
2317 |
" |
|
615 | 2318 |
'Make.proto' asFilename isSymbolicLink |
2319 |
'Makefile' asFilename isSymbolicLink |
|
2320 |
" |
|
2321 |
! |
|
2322 |
||
2629 | 2323 |
isVolumeAbsolute |
2324 |
"return true, if the receiver represents an absolute pathname |
|
2325 |
on some disk volume (MSDOS only)" |
|
2326 |
||
2327 |
^ false |
|
2906 | 2328 |
|
2329 |
"Modified: 7.9.1997 / 23:54:33 / cg" |
|
2629 | 2330 |
! |
2331 |
||
615 | 2332 |
isWritable |
2333 |
"return true, if such a file exists and is writable." |
|
2334 |
||
2947 | 2335 |
^ OperatingSystem isWritable:(self osNameForFile) |
615 | 2336 |
|
2337 |
" |
|
2338 |
'/foo/bar' asFilename isWritable |
|
2339 |
'/tmp' asFilename isWritable |
|
2340 |
'Makefile' asFilename isWritable |
|
328 | 2341 |
" |
174 | 2342 |
! |
2343 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2344 |
separator |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2345 |
"return the directory-separator character" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2346 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2347 |
^ self class separator |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2348 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2349 |
"Modified: 29.2.1996 / 20:52:01 / cg" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2350 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2351 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2352 |
!Filename methodsFor:'queries-contents'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2353 |
|
3865 | 2354 |
binaryContentsOfEntireFile |
3864 | 2355 |
"return the binary contents of the file as a byteArray; |
2356 |
or nil, if the file is unreadable." |
|
2357 |
||
2358 |
|s contents| |
|
2359 |
||
2360 |
s := self readStream. |
|
2361 |
s isNil ifTrue:[^ nil]. |
|
2362 |
s binary. |
|
2363 |
[ |
|
2364 |
contents := s contentsOfEntireFile |
|
2365 |
] valueNowOrOnUnwindDo:[s close]. |
|
2366 |
^ contents |
|
2367 |
||
3865 | 2368 |
"Created: / 3.10.1998 / 17:56:39 / cg" |
3864 | 2369 |
! |
2370 |
||
1540 | 2371 |
contents |
2372 |
"return the contents of the file as a collection of lines; |
|
3876 | 2373 |
or nil, if the file is unreadable. |
2374 |
See also #contentsOfEntireFile, which returns a string for textFiles." |
|
1540 | 2375 |
|
2376 |
|s contents| |
|
2377 |
||
2378 |
s := self readStream. |
|
2379 |
s isNil ifTrue:[^ nil]. |
|
2380 |
||
2381 |
[ |
|
3876 | 2382 |
contents := s contents |
1540 | 2383 |
] valueNowOrOnUnwindDo:[s close]. |
2384 |
^ contents |
|
2385 |
||
3876 | 2386 |
"Modified: / 2.7.1996 / 12:49:45 / stefan" |
2387 |
"Created: / 11.7.1996 / 14:09:11 / cg" |
|
2388 |
"Modified: / 15.10.1998 / 11:41:45 / cg" |
|
1540 | 2389 |
! |
2390 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2391 |
contentsOfEntireFile |
1540 | 2392 |
"return the contents of the file as a string; |
3876 | 2393 |
or nil, if the file is unreadable. |
2394 |
See also #contents, which returns the lines as stringCollection for textFiles." |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2395 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2396 |
|s contents| |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2397 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2398 |
s := self readStream. |
1535 | 2399 |
s isNil ifTrue:[^ nil]. |
2400 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2401 |
[ |
3876 | 2402 |
contents := s contentsOfEntireFile |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2403 |
] valueNowOrOnUnwindDo:[s close]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2404 |
^ contents |
1523 | 2405 |
|
3876 | 2406 |
"Modified: / 2.7.1996 / 12:49:45 / stefan" |
2407 |
"Modified: / 15.10.1998 / 11:42:05 / cg" |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2408 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2409 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2410 |
directoryContents |
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2411 |
"return the contents of the directory as a collection of strings. |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2412 |
This excludes any entries for '.' or '..'." |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2413 |
|
2946
c61e7226a7eb
#directoryContents no longer uses FileDirectory.
Stefan Vogel <sv@exept.de>
parents:
2944
diff
changeset
|
2414 |
|s contents| |
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2415 |
s := DirectoryStream directoryNamed:(self osNameForDirectoryContents). |
3713
881d419652f3
care for non-existing directory - before removing '.' and '..'
Claus Gittinger <cg@exept.de>
parents:
3677
diff
changeset
|
2416 |
s isNil ifTrue:[^nil]. |
881d419652f3
care for non-existing directory - before removing '.' and '..'
Claus Gittinger <cg@exept.de>
parents:
3677
diff
changeset
|
2417 |
|
881d419652f3
care for non-existing directory - before removing '.' and '..'
Claus Gittinger <cg@exept.de>
parents:
3677
diff
changeset
|
2418 |
contents := s contents. |
881d419652f3
care for non-existing directory - before removing '.' and '..'
Claus Gittinger <cg@exept.de>
parents:
3677
diff
changeset
|
2419 |
s close. |
2946
c61e7226a7eb
#directoryContents no longer uses FileDirectory.
Stefan Vogel <sv@exept.de>
parents:
2944
diff
changeset
|
2420 |
|
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2421 |
contents remove:'.' ifAbsent:nil. |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2422 |
contents remove:'..' ifAbsent:nil. |
2946
c61e7226a7eb
#directoryContents no longer uses FileDirectory.
Stefan Vogel <sv@exept.de>
parents:
2944
diff
changeset
|
2423 |
^ contents. |
c61e7226a7eb
#directoryContents no longer uses FileDirectory.
Stefan Vogel <sv@exept.de>
parents:
2944
diff
changeset
|
2424 |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2425 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2426 |
'.' asFilename directoryContents |
2946
c61e7226a7eb
#directoryContents no longer uses FileDirectory.
Stefan Vogel <sv@exept.de>
parents:
2944
diff
changeset
|
2427 |
'/XXXdoesNotExist' asFilename directoryContents |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2428 |
" |
2946
c61e7226a7eb
#directoryContents no longer uses FileDirectory.
Stefan Vogel <sv@exept.de>
parents:
2944
diff
changeset
|
2429 |
|
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2430 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2431 |
"Modified: / 3.8.1998 / 21:36:21 / cg" |
2960 | 2432 |
! |
2433 |
||
2434 |
fullDirectoryContents |
|
2435 |
"return the full contents of the directory as a collection of strings. |
|
2436 |
This is much like #directoryContents, but includes an entry for the |
|
2437 |
parent directory, if there is one." |
|
2438 |
||
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
2439 |
|files| |
2960 | 2440 |
|
2441 |
files := self directoryContents. |
|
3302 | 2442 |
files isNil ifTrue:[ |
2443 |
"/ mhmh - that one does not exist |
|
2444 |
^ files |
|
2445 |
]. |
|
2960 | 2446 |
|
3843 | 2447 |
"/ add/remove parentDirectory if there is one/none |
2960 | 2448 |
|
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2449 |
files remove:'.' ifAbsent:nil. |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2450 |
self isRootDirectory ifTrue:[ |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2451 |
files remove:'..' ifAbsent:nil. |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2452 |
] ifFalse:[ |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2453 |
(files includes:'..') ifFalse:[ |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2454 |
files addFirst:'..'. |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
2455 |
] |
2960 | 2456 |
]. |
2457 |
^ files |
|
3046 | 2458 |
|
2459 |
" |
|
2460 |
'.' asFilename fullDirectoryContents |
|
2461 |
'/XXXdoesNotExist' asFilename fullDirectoryContents |
|
3843 | 2462 |
'd:\FET' asFilename fullDirectoryContents |
3046 | 2463 |
" |
2464 |
||
3843 | 2465 |
"Modified: / 21.9.1998 / 15:33:07 / cg" |
3867
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2466 |
! |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2467 |
|
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2468 |
recursiveDirectoryContents |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2469 |
"return the contents of the directory and all subdirectories |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2470 |
as a collection of strings. |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2471 |
This excludes any entries for '.' or '..'. |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2472 |
Subdirectory files are included with a relative pathname. |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2473 |
Warning: this may take a long time to execute." |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2474 |
|
3868 | 2475 |
|fileNames dirNames| |
2476 |
||
2477 |
fileNames := OrderedCollection new. |
|
2478 |
dirNames := OrderedCollection new. |
|
3867
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2479 |
self directoryContents do:[:f | |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2480 |
(self construct:f) isDirectory ifTrue:[ |
3868 | 2481 |
dirNames add:f |
3867
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2482 |
] ifFalse:[ |
3868 | 2483 |
fileNames add:f |
3867
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2484 |
] |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2485 |
]. |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2486 |
|
3868 | 2487 |
dirNames do:[:dN | |
3867
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2488 |
|dd subFiles| |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2489 |
|
3868 | 2490 |
dd := dN asFilename. |
2491 |
subFiles := (self construct:dN) recursiveDirectoryContents. |
|
2492 |
fileNames addAll:(subFiles collect:[:f | dd constructString:f]) |
|
3867
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2493 |
]. |
3868 | 2494 |
^ fileNames. |
3867
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2495 |
|
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2496 |
" |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2497 |
'.' asFilename recursiveDirectoryContents |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2498 |
'../../clients' asFilename recursiveDirectoryContents |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2499 |
" |
91b0773fe260
added #recursiveDirectoryContents
Claus Gittinger <cg@exept.de>
parents:
3865
diff
changeset
|
2500 |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2501 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2502 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2503 |
!Filename methodsFor:'queries-path & name'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2504 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2505 |
baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2506 |
"return my baseName as a string. |
2012 | 2507 |
- thats the file/directory name without leading parent-dirs. |
2922 | 2508 |
(i.e. '/usr/lib/st/file' asFilename baseName -> 'file' |
2509 |
and '/usr/lib' asFilename baseName -> lib). |
|
2510 |
This method does not check if the path is valid |
|
2511 |
||
2911 | 2512 |
See also: #pathName, #directoryName and #directoryPathName. |
2513 |
Compatibility note: use #tail for ST-80 compatibility." |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2514 |
|
2922 | 2515 |
|len index sep endIdx| |
2516 |
||
2517 |
sep := self separator. |
|
2518 |
len := nameString size. |
|
2519 |
((len == 1) and:[(nameString at:1) == sep]) ifTrue:[ |
|
2520 |
^ nameString |
|
2521 |
]. |
|
2522 |
||
2523 |
endIdx := len. |
|
2524 |
len > 1 ifTrue:[ |
|
2525 |
(nameString at:len) == sep ifTrue:[endIdx := endIdx - 1]. |
|
2526 |
]. |
|
2527 |
index := nameString lastIndexOf:sep startingAt:len-1. |
|
2528 |
index == 0 ifTrue:[ |
|
2529 |
^ nameString copyTo:endIdx |
|
2530 |
]. |
|
2531 |
^ nameString copyFrom:(index+1) to:endIdx |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2532 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2533 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2534 |
'/foo/bar' asFilename baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2535 |
'.' asFilename baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2536 |
'..' asFilename baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2537 |
'../..' asFilename baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2538 |
'../../libbasic' asFilename baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2539 |
'../../libpr' asFilename baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2540 |
'../../libbasic/Object.st' asFilename baseName |
3851 | 2541 |
'/' asFilename baseName |
2542 |
'\' asFilename baseName |
|
2543 |
'c:\' asFilename baseName |
|
2544 |
'\\idefix' asFilename baseName |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2545 |
" |
2012 | 2546 |
|
3851 | 2547 |
"Modified: / 24.9.1998 / 13:06:23 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2548 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2549 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2550 |
directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2551 |
"return the directory name part of the file/directory as a new filename. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2552 |
- thats a filename for the directory where the file/dir represented by |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2553 |
the receiver is contained in. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2554 |
(this is almost equivalent to #directoryName or #head, but returns |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2555 |
a Filename instance instead of a string )." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2556 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2557 |
^ self directoryName asFilename |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2558 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2559 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2560 |
'/foo/bar' asFilename directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2561 |
'/foo/bar' asFilename directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2562 |
'/foo/bar' asFilename head |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2563 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2564 |
'.' asFilename directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2565 |
'..' asFilename directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2566 |
'../..' asFilename directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2567 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2568 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2569 |
"Modified: 29.2.1996 / 20:50:14 / cg" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2570 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2571 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2572 |
directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2573 |
"return the directory name part of the file/directory as a string. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2574 |
- thats the name of the directory where the file/dir represented by |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2575 |
the receiver is contained in. |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2576 |
This method does not check if the path is valid. |
2922 | 2577 |
|
2578 |
(i.e. '/usr/lib/st/file' asFilename directoryName -> '/usr/lib/st' |
|
2579 |
and '/usr/lib' asFilename directoryName -> /usr'). |
|
2580 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2581 |
(this is almost equivalent to #directory, but returns |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2582 |
a string instead of a Filename instance). |
2922 | 2583 |
|
2012 | 2584 |
See also: #pathName, #directoryPathName and #baseName. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2585 |
Compatibility note: use #head for ST-80 compatibility." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2586 |
|
3954 | 2587 |
|index sep sepString p rest| |
2922 | 2588 |
|
2589 |
sep := self separator. |
|
2590 |
sepString := sep asString. |
|
2591 |
(nameString = sepString) ifTrue:[ |
|
2592 |
"/ |
|
2593 |
"/ the trivial '/' case |
|
2594 |
"/ |
|
2595 |
^ nameString |
|
2596 |
]. |
|
2597 |
||
2598 |
"/ |
|
3893 | 2599 |
"/ strip off multiple trailing slashes |
2922 | 2600 |
"/ |
2601 |
p := nameString. |
|
2602 |
[p endsWith:sepString] whileTrue:[ |
|
2603 |
(p = sepString) ifTrue:[ |
|
2604 |
^ p |
|
2605 |
]. |
|
2606 |
p := p copyWithoutLast:1 |
|
2607 |
]. |
|
2608 |
||
3886
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
2609 |
"/ strip off trailing components |
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
2610 |
|
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2611 |
index := p lastIndexOf:sep startingAt:p size. |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2612 |
index == 0 ifTrue:[ |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2613 |
"/ no separator found |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2614 |
p = '.' ifTrue:[ |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2615 |
^ '..' |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2616 |
]. |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2617 |
p = '..' ifTrue:[ |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2618 |
^ '../..' |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2619 |
]. |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2620 |
^ '.' |
2922 | 2621 |
]. |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2622 |
rest := p copyFrom:(index+1). |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2623 |
rest = '.' ifTrue:[ |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2624 |
^ p , '.' |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2625 |
]. |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2626 |
rest = '..' ifTrue:[ |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2627 |
^ p , '/..' |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2628 |
]. |
3893 | 2629 |
index == 1 ifTrue:[ |
2630 |
^ '/' |
|
2631 |
]. |
|
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2632 |
^ p copyTo:(index - 1) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2633 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2634 |
" |
3893 | 2635 |
'/home' asFilename directoryName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2636 |
'/foo/bar/' asFilename directoryName |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2637 |
'/foo/bar/' asFilename directory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2638 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2639 |
'/foo/bar' asFilename directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2640 |
'bitmaps' asFilename directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2641 |
'bitmaps' asFilename directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2642 |
'.' asFilename directoryName |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2643 |
'.' asFilename directoryPathName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2644 |
'..' asFilename directoryName |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2645 |
'..' asFilename directoryPathName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2646 |
'../..' asFilename directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2647 |
'../..' asFilename directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2648 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2649 |
|
3886
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
2650 |
"Modified: / 7.9.1995 / 10:42:03 / claus" |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
2651 |
"Modified: / 21.10.1998 / 22:52:25 / cg" |
3893 | 2652 |
"Modified: / 27.10.1998 / 13:19:26 / ps" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2653 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2654 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2655 |
directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2656 |
"return the full directory pathname part of the file/directory as a string. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2657 |
- thats the full pathname of the directory where the file/dir represented by |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2658 |
the receiver is contained in. |
2012 | 2659 |
See also: #pathName, #directoryName, #directory and #baseName" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2660 |
|
2922 | 2661 |
^ self pathName asFilename directoryName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2662 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2663 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2664 |
'/foo/bar/' asFilename directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2665 |
'/foo/bar' asFilename directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2666 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2667 |
'.' asFilename directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2668 |
'.' asFilename directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2669 |
'.' asFilename directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2670 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2671 |
'..' asFilename directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2672 |
'..' asFilename directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2673 |
'..' asFilename directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2674 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2675 |
'../..' asFilename directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2676 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2677 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2678 |
"Modified: 7.9.1995 / 10:42:13 / claus" |
2012 | 2679 |
"Modified: 21.12.1996 / 15:21:57 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2680 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2681 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2682 |
filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2683 |
"try to complete the receiver filename. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2684 |
This method has both a return value and a side effect on the receiver: |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2685 |
it returns a collection of matching filename objects, |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2686 |
and leaves changes the receivers filename-string to the longest common |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2687 |
match. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2688 |
If none matches, the returned collection is empty and the recevier is unchanged. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2689 |
If there is only one match, the size of the returned collection is exactly 1, |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2690 |
containing the fully expanded filename and the receivers name is changed to it." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2691 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2692 |
^ self filenameCompletionIn:nil |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2693 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2694 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2695 |
'mak' asFilename filenameCompletion |
1517 | 2696 |
'Make' asFilename filenameCompletion |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2697 |
'Makef' asFilename filenameCompletion;yourself |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2698 |
'/u' asFilename filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2699 |
'../../libpr' asFilename inspect filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2700 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2701 |
|
1517 | 2702 |
"Modified: 3.7.1996 / 10:53:51 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2703 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2704 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2705 |
filenameCompletionIn:aDirectory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2706 |
"try to complete the receiver filename. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2707 |
This method has both a return value and a side effect on the receiver: |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2708 |
it returns a collection of matching filename objects, |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2709 |
and leaves changes the receivers filename-string to the longest common |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2710 |
match. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2711 |
If none matches, the returned collection is empty and the recevier is unchanged. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2712 |
If there is only one match, the size of the returned collection is exactly 1, |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2713 |
containing the fully expanded filename and the receivers name is changed to it." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2714 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2715 |
|dir baseName matching matchLen try allMatching |
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
2716 |
sepString parentString prefix nMatch nm caseless lcBaseName| |
3666 | 2717 |
|
2718 |
nm := self nameWithSpecialExpansions:nameString. |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2719 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2720 |
sepString := self class separator asString. |
3666 | 2721 |
(nm endsWith:sepString) ifTrue:[ |
2906 | 2722 |
^ #() |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2723 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2724 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2725 |
parentString := self class parentDirectoryName. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2726 |
baseName := self baseName. |
3666 | 2727 |
baseName ~= nm ifTrue:[ |
2906 | 2728 |
prefix := self directoryName. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2729 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2730 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2731 |
self isAbsolute ifTrue:[ |
2906 | 2732 |
dir := self directory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2733 |
] ifFalse:[ |
2906 | 2734 |
aDirectory isNil ifTrue:[ |
2735 |
dir := self directory |
|
2736 |
] ifFalse:[ |
|
3666 | 2737 |
dir := (aDirectory construct:nm) directory |
2906 | 2738 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2739 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2740 |
|
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
2741 |
caseless := self class isCaseSensitive not. |
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
2742 |
caseless ifTrue:[ |
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
2743 |
lcBaseName := baseName asLowercase |
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
2744 |
]. |
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
2745 |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2746 |
matching := OrderedCollection new. |
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
2747 |
dir class errorReporter openErrorSignal handle:[:ex| |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
2748 |
^ #(). |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
2749 |
] do:[ |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
2750 |
dir directoryContents do:[:fileName | |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
2751 |
((fileName ~= '.') and:[fileName ~= parentString]) ifTrue:[ |
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
2752 |
((caseless and:[fileName asLowercase startsWith:lcBaseName]) |
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
2753 |
or:[caseless not and:[fileName startsWith:baseName]]) ifTrue:[ |
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
2754 |
matching add:fileName |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
2755 |
] |
2906 | 2756 |
] |
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
2757 |
]. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2758 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2759 |
(nMatch := matching size) > 1 ifTrue:[ |
2906 | 2760 |
" |
2761 |
find the longest common prefix |
|
2762 |
" |
|
2763 |
matchLen := baseName size. |
|
2764 |
matchLen > matching first size ifTrue:[ |
|
2765 |
try := baseName. |
|
2766 |
allMatching := false |
|
2767 |
] ifFalse:[ |
|
2768 |
try := matching first copyTo:matchLen. |
|
2769 |
allMatching := true. |
|
2770 |
]. |
|
2771 |
||
2772 |
[allMatching] whileTrue:[ |
|
2773 |
matching do:[:aName | |
|
2774 |
(aName startsWith:try) ifFalse:[ |
|
2775 |
allMatching := false |
|
2776 |
] |
|
2777 |
]. |
|
2778 |
allMatching ifTrue:[ |
|
2779 |
matchLen < matching first size ifTrue:[ |
|
2780 |
matchLen := matchLen + 1. |
|
2781 |
try := matching first copyTo:matchLen. |
|
2782 |
] ifFalse:[ |
|
2783 |
allMatching := false |
|
2784 |
] |
|
2785 |
] ifFalse:[ |
|
2786 |
try := matching first copyTo:matchLen - 1. |
|
2787 |
] |
|
2788 |
]. |
|
2789 |
" |
|
2790 |
and set my name to the last full match |
|
2791 |
" |
|
3666 | 2792 |
nameString := nm := try |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2793 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2794 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2795 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2796 |
if I had a directory-prefix, change names in collection ... |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2797 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2798 |
prefix notNil ifTrue:[ |
2906 | 2799 |
prefix = sepString ifTrue:[ |
2800 |
"/ avoid introducing double slashes |
|
2801 |
prefix := '' |
|
2802 |
]. |
|
2803 |
matching := matching collect:[:n | prefix , sepString , n]. |
|
2804 |
nMatch == 1 ifTrue:[ |
|
3666 | 2805 |
nameString := nm := matching first |
2906 | 2806 |
] ifFalse:[ |
2807 |
nMatch > 1 ifTrue:[ |
|
3666 | 2808 |
nameString := nm := prefix , sepString , nm |
2906 | 2809 |
] |
2810 |
] |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2811 |
] ifFalse:[ |
2906 | 2812 |
nMatch == 1 ifTrue:[ |
3666 | 2813 |
nameString := nm := matching first |
2906 | 2814 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2815 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2816 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2817 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2818 |
return the match-set, so caller can decide what to do |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2819 |
(i.e. show the matches, output a warning etc ...) |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2820 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2821 |
^ matching |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2822 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2823 |
" trivial cases: |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2824 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2825 |
'../' asFilename filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2826 |
'/' asFilename filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2827 |
'/usr/' asFilename filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2828 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2829 |
'mak' asFilename filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2830 |
'Make' asFilename filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2831 |
'Makef' asFilename filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2832 |
'/u' asFilename filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2833 |
'../../libpr' asFilename filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2834 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2835 |
|
3666 | 2836 |
"Modified: / 22.9.1997 / 18:03:33 / stefan" |
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
2837 |
"Modified: / 20.8.1998 / 01:54:14 / cg" |
2903 | 2838 |
! |
2839 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2840 |
head |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2841 |
"return the directory name as a string. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2842 |
An alias for directoryName, for ST-80 compatiblity. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2843 |
(this is almost equivalent to #directory, but returns |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2844 |
a string instead of a Filename instance)" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2845 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2846 |
^ self directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2847 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2848 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2849 |
Filename currentDirectory head |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2850 |
'Makefile' asFilename head |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2851 |
'/foo/bar/baz.st' asFilename head |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2852 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2853 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2854 |
"Modified: 29.2.1996 / 20:21:25 / cg" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2855 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2856 |
|
2987
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
2857 |
localPathName |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
2858 |
"return the full pathname of the file represented by the receiver, |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
2859 |
but without any volume information. |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
2860 |
Only makes a difference on MSDOS & VMS systems." |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
2861 |
|
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
2862 |
^ self pathName |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
2863 |
! |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
2864 |
|
615 | 2865 |
name |
2866 |
"return the name of the file represented by the receiver as a string. |
|
883 | 2867 |
This may or may not be a relative name (i.e. include ..'s). |
615 | 2868 |
See also: pathName" |
174 | 2869 |
|
615 | 2870 |
self isAbsolute ifTrue:[^ self pathName]. |
2871 |
^ nameString |
|
174 | 2872 |
|
2873 |
" |
|
615 | 2874 |
'/foo/bar' asFilename name |
2875 |
'/foo/bar' asFilename pathName |
|
2876 |
'.' asFilename name |
|
2877 |
'.' asFilename pathName |
|
2878 |
'../..' asFilename name |
|
883 | 2879 |
'../..' asFilename pathName |
615 | 2880 |
'bitmaps' asFilename name |
2881 |
'bitmaps' asFilename pathName |
|
2882 |
'/tmp/../usr' asFilename name |
|
883 | 2883 |
'/tmp/../usr' asFilename pathName |
2884 |
'source/..' asFilename name |
|
2885 |
'source/..' asFilename pathName |
|
2886 |
'/tmp/..' asFilename name |
|
2887 |
'/tmp/..' asFilename pathName |
|
92 | 2888 |
" |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
2889 |
|
883 | 2890 |
"Modified: 18.1.1996 / 21:36:27 / cg" |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
2891 |
! |
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
2892 |
|
615 | 2893 |
pathName |
2894 |
"return the full pathname of the file represented by the receiver, |
|
1317 | 2895 |
as a string. This will not include ..'s. |
2896 |
If the path represented by the receiver does NOT represent a valid path, |
|
2897 |
no compression will be done (for now; this may change). |
|
2898 |
See also: name" |
|
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
2899 |
|
1317 | 2900 |
|p| |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
2901 |
|
1317 | 2902 |
"/ sep := self class separator. |
2903 |
"/ (nameString startsWith:sep) ifTrue:[ |
|
2904 |
"/ parentName := self class parentDirectoryName. |
|
2905 |
"/ (nameString findString:parentName) == 0 ifTrue:[ |
|
2906 |
"/ ^ nameString |
|
2907 |
"/ ] |
|
2908 |
"/ ]. |
|
2909 |
p := OperatingSystem pathNameOf:nameString. |
|
2910 |
^ p |
|
2 | 2911 |
|
92 | 2912 |
" |
1317 | 2913 |
'/foo/bar' asFilename pathName |
2914 |
'.' asFilename pathName |
|
2915 |
'../..' asFilename pathName |
|
2916 |
'../..' asFilename name |
|
2917 |
'/tmp/../usr' asFilename pathName |
|
2918 |
'/././usr' asFilename pathName |
|
92 | 2919 |
" |
159 | 2920 |
|
1317 | 2921 |
"Modified: 27.4.1996 / 18:19:52 / cg" |
174 | 2922 |
! |
2923 |
||
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2924 |
physicalPathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2925 |
"return the full pathname of the physical file represented by the receiver, |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2926 |
If the receiver represents a symbolic link, thats the fileName of the |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2927 |
final target. Otherwise, its the receivers pathName itself. |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2928 |
If any file along the symbolic path does not exist (i.e. is a broken link), |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2929 |
nil is returned." |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2930 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2931 |
|t target path| |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2932 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2933 |
self isSymbolicLink ifFalse:[ |
2629 | 2934 |
self exists ifFalse:[^ nil]. |
2935 |
^ self pathName |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2936 |
]. |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2937 |
t := self. |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2938 |
[t isSymbolicLink] whileTrue:[ |
2629 | 2939 |
path := t linkInfo path. |
2940 |
path isNil ifTrue:[ |
|
2941 |
"/ cannot happen |
|
2942 |
^ nil |
|
2943 |
]. |
|
2944 |
target := t directoryName asFilename construct:path. |
|
2945 |
target exists ifFalse:[^ nil]. |
|
2946 |
t := target asFilename |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2947 |
]. |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2948 |
t exists ifFalse:[^ nil]. |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2949 |
^ t pathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2950 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2951 |
" |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2952 |
'/foo/bar' asFilename physicalPathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2953 |
'.' asFilename physicalPathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2954 |
'../..' asFilename physicalPathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2955 |
'include/abbrev.stc' asFilename physicalPathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2956 |
" |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2957 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2958 |
"Modified: 21.12.1996 / 15:29:50 / cg" |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2959 |
! |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
2960 |
|
615 | 2961 |
tail |
2962 |
"the files name without directory prefix as a string. |
|
2963 |
An alias for baseName, for ST-80 compatiblity." |
|
174 | 2964 |
|
615 | 2965 |
^ self baseName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2966 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2967 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2968 |
Filename currentDirectory tail |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2969 |
'Makefile' asFilename tail |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2970 |
'/foo/bar/baz.st' asFilename tail |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2971 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2972 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2973 |
"Modified: 29.2.1996 / 20:19:50 / cg" |
2629 | 2974 |
! |
2975 |
||
2976 |
volume |
|
2977 |
"return the disc volume part of the name or an empty string. |
|
2906 | 2978 |
This is only used with MSDOS and VMS filenames |
2979 |
- by default (and on unix), an empty string is returned" |
|
2980 |
||
2629 | 2981 |
^ '' |
2906 | 2982 |
|
2983 |
"Modified: 8.9.1997 / 00:37:33 / cg" |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2984 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2985 |
|
2922 | 2986 |
!Filename methodsFor:'special accessing'! |
2987 |
||
3665 | 2988 |
nameWithSpecialExpansions:aString |
2989 |
"return the nameString, expanding any OS specific |
|
2990 |
macros. This should be redefined for OS's where such macros |
|
2991 |
are common. |
|
2992 |
On unix, a ~/ prefix is expanded to the users home dir (as in csh)" |
|
2993 |
||
2994 |
^ aString |
|
2995 |
||
2996 |
"Modified: / 21.7.1998 / 10:43:20 / cg" |
|
2997 |
"Created: / 21.7.1998 / 10:45:58 / cg" |
|
2998 |
! |
|
2999 |
||
2922 | 3000 |
osName |
3001 |
"special - return the OS's name for the receiver." |
|
3002 |
||
3003 |
self isDirectory ifTrue:[ |
|
3004 |
^ self osNameForDirectory |
|
3005 |
]. |
|
3006 |
^ self osNameForFile |
|
3007 |
! |
|
3008 |
||
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
3009 |
osNameForAccess |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
3010 |
"internal - return the OS's name for the receiver to |
3665 | 3011 |
access its fileInfo. |
3012 |
This may be redefined for systems, where a special suffix must be |
|
3013 |
added in order to access directories (or others) as a file. |
|
3014 |
(i.e. under VMS, a '.dir' suffix is added to access directories)" |
|
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
3015 |
|
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
3016 |
^ nameString |
3665 | 3017 |
|
3018 |
"Modified: / 21.7.1998 / 10:40:40 / cg" |
|
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
3019 |
! |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
3020 |
|
2922 | 3021 |
osNameForDirectory |
3753 | 3022 |
"internal - return the OS's name for the receiver to |
2922 | 3023 |
access it as a directory." |
3024 |
||
3025 |
^ nameString |
|
3753 | 3026 |
|
3027 |
"Modified: / 12.8.1998 / 14:44:32 / cg" |
|
2922 | 3028 |
! |
3029 |
||
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
3030 |
osNameForDirectoryContents |
3753 | 3031 |
"internal - return the OS's name for the receiver to |
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
3032 |
access it as a directory when reading its contents." |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
3033 |
|
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
3034 |
^ self osNameForDirectory |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
3035 |
|
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
3036 |
"Created: / 3.8.1998 / 21:36:06 / cg" |
3753 | 3037 |
"Modified: / 12.8.1998 / 14:44:34 / cg" |
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
3038 |
! |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
3039 |
|
2922 | 3040 |
osNameForFile |
3041 |
"internal - return the OS's name for the receiver to |
|
3042 |
access it as a file." |
|
3043 |
||
3044 |
^ nameString |
|
3045 |
! ! |
|
3046 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3047 |
!Filename methodsFor:'suffixes'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3048 |
|
2906 | 3049 |
hasSuffix:aSuffixString |
3050 |
"return true if my suffix is the same as aString. |
|
3051 |
This cares for systems, where case is ignored in filenames" |
|
3052 |
||
3053 |
|mySuffix| |
|
3054 |
||
3055 |
mySuffix := self suffix. |
|
3056 |
self class isCaseSensitive ifTrue:[ |
|
3057 |
^ mySuffix = aSuffixString |
|
3058 |
]. |
|
3059 |
^ mySuffix asLowercase = aSuffixString asLowercase |
|
3060 |
||
3061 |
" |
|
3062 |
'abc.st' asFilename hasSuffix:'st' |
|
3063 |
'abc.ST' asFilename hasSuffix:'st' |
|
3064 |
" |
|
3065 |
||
3066 |
"Modified: 7.9.1997 / 02:55:25 / cg" |
|
3067 |
! |
|
3068 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3069 |
prefixAndSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3070 |
"return an array consisting of my prefix and suffix. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3071 |
The suffix is the namepart after the final period character, |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3072 |
the prefix everything before, except for the period. |
1517 | 3073 |
The directory name part is stripped off (i.e. the returned prefix |
3074 |
will consist of the files basename only.) |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3075 |
(on some systems, the suffix-character may be different from a period). |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3076 |
For example, foo.bar.baz has a prefix of 'foo.bar' and a suffix of '.baz'. |
1517 | 3077 |
See also: #withoutSuffix and #withSuffix |
3078 |
Notice: |
|
2629 | 3079 |
there is currently no known system which uses other than |
3080 |
the period character as suffixCharacter." |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3081 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3082 |
|nm idx| |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3083 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3084 |
nm := self baseName. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3085 |
idx := nm lastIndexOf:(self class suffixSeparator). |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3086 |
idx == 0 ifTrue:[ |
2629 | 3087 |
^ Array with:nm with:'' |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3088 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3089 |
^ Array |
2629 | 3090 |
with:(nm copyTo:idx-1) |
3091 |
with:(nm copyFrom:idx+1) |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3092 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3093 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3094 |
'abc.st' asFilename prefixAndSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3095 |
'abc' asFilename prefixAndSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3096 |
'a.b.c' asFilename prefixAndSuffix |
1517 | 3097 |
'/foo/bar.c/baz.c' asFilename prefixAndSuffix |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3098 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3099 |
|parts| |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3100 |
parts := 'Object.st' asFilename prefixAndSuffix. |
1517 | 3101 |
((parts at:1) , '.o') asFilename |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3102 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3103 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3104 |
"Modified: 7.9.1995 / 11:15:42 / claus" |
1517 | 3105 |
"Modified: 3.7.1996 / 10:53:10 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3106 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3107 |
|
2906 | 3108 |
suffix |
3109 |
"return my suffix. |
|
3110 |
The suffix is the namepart after the final period character, |
|
3111 |
or the empty string, if the name does not contain a period." |
|
3112 |
||
3113 |
^ self prefixAndSuffix at:2 |
|
3114 |
||
3115 |
" |
|
3116 |
'abc.st' asFilename suffix |
|
3117 |
'abc' asFilename suffix |
|
3118 |
'a.b.c' asFilename suffix |
|
3119 |
" |
|
3120 |
||
3121 |
"Modified: 7.9.1995 / 11:09:03 / claus" |
|
3122 |
! |
|
3123 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3124 |
withSuffix:aSuffix |
2922 | 3125 |
"return a new filename for the receivers name with a different suffix. |
1993 | 3126 |
If the name already has a suffix, the new suffix replacaes it; |
3127 |
otherwise, the new suffix is simply appended to the name." |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3128 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3129 |
^ self class named: |
2629 | 3130 |
(self withoutSuffix name |
3131 |
, self class suffixSeparator asString |
|
3132 |
, aSuffix asString) |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3133 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3134 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3135 |
'abc.st' asFilename withSuffix:'o' |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3136 |
'abc' asFilename withSuffix:'o' |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3137 |
'a.b.c' asFilename withSuffix:'o' |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3138 |
'/foo/bar/baz.st' asFilename withSuffix:'c' |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3139 |
'/foo/bar/baz.c' asFilename withSuffix:'st' |
1517 | 3140 |
'/foo/bar.c/baz.c' asFilename withSuffix:'st' |
1993 | 3141 |
'/foo/bar.c/baz' asFilename withSuffix:'st' |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3142 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3143 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3144 |
"Modified: 7.9.1995 / 11:15:42 / claus" |
1993 | 3145 |
"Modified: 11.12.1996 / 16:01:02 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3146 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3147 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3148 |
withoutSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3149 |
"return a new filename for the receivers name without the suffix. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3150 |
If the name has no suffix, the receiver is returned." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3151 |
|
2922 | 3152 |
|nm idx| |
3153 |
||
3154 |
nm := self baseName. |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3155 |
idx := nameString lastIndexOf:(self class suffixSeparator). |
2922 | 3156 |
(idx == 0) ifTrue:[^ self]. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3157 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3158 |
^ self class named:(nameString copyTo:(idx - 1)) |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3159 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3160 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3161 |
'abc.st' asFilename withoutSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3162 |
'abc' asFilename withoutSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3163 |
'a.b.c' asFilename withoutSuffix |
1516 | 3164 |
'/foo/bar/baz.c' asFilename withoutSuffix |
3165 |
'/foo/bar/baz/foo.c/bar' asFilename withoutSuffix |
|
3166 |
'/foo/bar/baz/foo.c/bar.c' asFilename withoutSuffix |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3167 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3168 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3169 |
"Modified: 7.9.1995 / 11:15:42 / claus" |
1516 | 3170 |
"Modified: 3.7.1996 / 10:49:58 / cg" |
174 | 3171 |
! ! |
3172 |
||
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3173 |
!Filename class methodsFor:'documentation'! |
630 | 3174 |
|
3175 |
version |
|
3954 | 3176 |
^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.148 1999-01-15 20:19:21 cg Exp $' |
630 | 3177 |
! ! |
2906 | 3178 |
Filename initialize! |