--- a/Filename.st Mon Oct 11 10:01:24 1999 +0200
+++ b/Filename.st Mon Oct 11 11:01:44 1999 +0200
@@ -2477,7 +2477,7 @@
binaryContentsOfEntireFile
"return the binary contents of the file as a byteArray;
- or nil, if the file is unreadable."
+ or nil, if the file is unreadable/non-existing."
|s contents|
@@ -2494,7 +2494,7 @@
contents
"return the contents of the file as a collection of lines;
- or nil, if the file is unreadable.
+ or nil, if the file is unreadable/non-existing.
See also #contentsOfEntireFile, which returns a string for textFiles."
|s contents|
@@ -2514,7 +2514,7 @@
contentsOfEntireFile
"return the contents of the file as a string;
- or nil, if the file is unreadable.
+ or nil, if the file is unreadable/non-existing.
See also #contents, which returns the lines as stringCollection for textFiles."
|s contents|
@@ -2533,7 +2533,10 @@
directoryContents
"return the contents of the directory as a collection of strings.
- This excludes any entries for '.' or '..'."
+ This excludes any entries for '.' or '..'.
+ Returns nil for non-existing directories; however, this behavior
+ may be changed in the near future, to raise an exception instead.
+ So users of this method better test for existing directory before."
|s contents|
s := DirectoryStream directoryNamed:(self osNameForDirectoryContents).
@@ -2555,10 +2558,64 @@
"Modified: / 3.8.1998 / 21:36:21 / cg"
!
+directoryContentsAsFilenames
+ "return the contents of the directory as a collection of filenames.
+ This excludes any entries for '.' or '..'.
+ Returns nil for non-existing directories; however, this behavior
+ may be changed in the near future, to raise an exception instead.
+ So users of this method better test for existing directory before."
+
+ |names|
+
+ names := self directoryContents.
+ names isNil ifTrue:[^ nil].
+ ^ names asOrderedCollection collect:[:entry | self construct:entry].
+
+ "
+ '.' asFilename directoryContentsAsFilenames
+ '/XXXdoesNotExist' asFilename directoryContentsAsFilenames
+ "
+
+!
+
+directoryContentsDo:aBlock
+ "evaluate aBlock for each filein the directory represented by the receiver.
+ The block is invoked with a string as argument.
+ The enumarations order is undefined - i.e. usually NOT sorted by
+ filenames (but by creation time - on some systems).
+ This excludes entries for '.' or '..'.
+ NoOp for non-existing directories; however, this behavior
+ may be changed in the near future, to raise an exception instead.
+ So users of this method better test for existing directory before."
+
+ |s entry|
+
+ s := DirectoryStream directoryNamed:(self osNameForDirectoryContents).
+ s isNil ifTrue:[^nil].
+
+ [s atEnd] whileFalse:[
+ entry := s nextLine.
+ aBlock value:entry onUnwindDo:[
+ s close
+ ]
+ ].
+ s close
+
+ "
+ '.' asFilename directoryContentsDo:[:fn | Transcript showCR:fn].
+ "
+
+ "Modified: / 18.9.1997 / 18:42:23 / stefan"
+ "Modified: / 3.8.1998 / 21:36:21 / cg"
+!
+
fullDirectoryContents
"return the full contents of the directory as a collection of strings.
This is much like #directoryContents, but includes an entry for the
- parent directory, if there is one."
+ parent directory, if there is one.
+ Returns nil for non-existing directories; however, this behavior
+ may be changed in the near future, to raise an exception instead.
+ So users of this method better test for existing directory before."
|files|
@@ -3307,6 +3364,6 @@
!Filename class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.162 1999-09-26 14:13:40 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.163 1999-10-11 09:01:44 cg Exp $'
! !
Filename initialize!