equal
deleted
inserted
replaced
24 |
24 |
25 FileDirectories represent directories in the underlying host system. |
25 FileDirectories represent directories in the underlying host system. |
26 They provide various methods to create/delete and query for files and/or |
26 They provide various methods to create/delete and query for files and/or |
27 directories. |
27 directories. |
28 |
28 |
29 %W% %E% |
29 $Header: /cvs/stx/stx/libbasic/FileDirectory.st,v 1.3 1993-10-13 00:15:54 claus Exp $ |
30 |
30 |
31 written winter 89 by claus |
31 written winter 89 by claus |
32 '! |
32 '! |
33 |
33 |
34 !FileDirectory class methodsFor:'initialization'! |
34 !FileDirectory class methodsFor:'initialization'! |
38 ObjectMemory addDependent:self |
38 ObjectMemory addDependent:self |
39 ! |
39 ! |
40 |
40 |
41 update:something |
41 update:something |
42 something == #restarted ifTrue:[ |
42 something == #restarted ifTrue:[ |
43 pathOfCurrentDirectory := nil |
43 pathOfCurrentDirectory := nil |
44 ] |
44 ] |
45 ! ! |
45 ! ! |
46 |
46 |
47 !FileDirectory class methodsFor:'instance creation'! |
47 !FileDirectory class methodsFor:'instance creation'! |
48 |
48 |
209 # include <sys/param.h> |
209 # include <sys/param.h> |
210 |
210 |
211 char nameBuffer[MAXPATHLEN + 1]; |
211 char nameBuffer[MAXPATHLEN + 1]; |
212 |
212 |
213 if (realpath(_stringVal(_INST(pathName)), nameBuffer)) { |
213 if (realpath(_stringVal(_INST(pathName)), nameBuffer)) { |
214 fullPathName = _MKSTRING(nameBuffer COMMA_CON); |
214 fullPathName = _MKSTRING(nameBuffer COMMA_CON); |
215 } |
215 } |
216 #endif |
216 #endif |
217 %} |
217 %} |
218 . |
218 . |
219 fullPathName notNil ifTrue:[ |
219 fullPathName notNil ifTrue:[ |
220 pathName := fullPathName. |
220 pathName := fullPathName. |
221 lazy := false |
221 lazy := false |
222 ] ifFalse:[ |
222 ] ifFalse:[ |
223 "since there might be symbolic links and other stuff involved, |
223 "since there might be symbolic links and other stuff involved, |
224 better trust pwd than removing '..' by ourself |
224 better trust pwd than removing '..' by ourself |
225 - although this is very slow" |
225 - although this is very slow" |
226 |
226 |
356 |
356 |
357 ^ OperatingSystem isDirectory:pathName |
357 ^ OperatingSystem isDirectory:pathName |
358 "(FileDirectory directoryNamed:'fooBar') exists" |
358 "(FileDirectory directoryNamed:'fooBar') exists" |
359 ! |
359 ! |
360 |
360 |
|
361 isEmpty |
|
362 "return true, if the directory is empty; |
|
363 redefined since '.' and '..' do not count as entries here." |
|
364 |
|
365 self do:[:fName | |
|
366 ((fName ~= '.') and:[fName ~= '..']) ifTrue:[^ false]. |
|
367 ]. |
|
368 ^ true |
|
369 ! |
|
370 |
361 infoOf:name |
371 infoOf:name |
362 "return an array filled with file info for the file 'aFileName'; |
372 "return an array filled with file info for the file 'aFileName'; |
363 return nil if such a file does not exist" |
373 return nil if such a file does not exist" |
364 |
374 |
365 (name startsWith:'/') ifTrue:[ |
375 (name startsWith:'/') ifTrue:[ |