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