Filename.st
changeset 1318 25b5f52aa644
parent 1317 cc737e0fdf48
child 1422 9a0b792f2953
--- a/Filename.st	Sat Apr 27 20:11:33 1996 +0200
+++ b/Filename.st	Tue Apr 30 12:18:03 1996 +0200
@@ -58,6 +58,13 @@
 
         Filename newTemporary writeStream
 
+    Beside lots of protocol to query for a files attributes, the class
+    protocol offers methods for filename completion, to construct pathes
+    (in an OS-independent way) and to create temporary files.
+    Especially the path-construction methods (i.e. #construct:) is highly
+    recommended in order to avoid having OS details (like directory separators
+    being slash or backslash) spreaded in your application.
+
     [author:]
         Claus Gittinger
 
@@ -456,10 +463,10 @@
 filenameCompletionFor:aString directory:inDirectory directoriesOnly:directoriesOnly filesOnly:filesOnly ifMultiple:aBlock
     "perform filename completion on aString in some directory;
      return the longest matching filename prefix as a string.
-     If directoriesOnly and filesOnly are true, only directories and files
-     are considered respectively. If multiple files match, the exception
-     block aBlock is evaluated with a filename representing the directory
-     (where the match was done) as argument.
+     The boolean directoriesOnly and filesOnly control respectively,
+     if only directories or only regular files are to be considered for completion.
+     If multiple files match, the exception block aBlock is evaluated with a 
+     filename representing the directory (where the match was done) as argument.
      (this may be different from the inDirectory argument, if aString is absolute
       or starts with ../)"
 
@@ -471,8 +478,8 @@
     "
     words := s asCollectionOfWords.
     words size == 0 ifTrue:[
-	aBlock value:'.' asFilename.
-	^ ''
+        aBlock value:'.' asFilename.
+        ^ ''
     ].
 
     f := words last asFilename.
@@ -482,22 +489,22 @@
     dir := f directory.
 
     directoriesOnly ifTrue:[
-	matchSet := matchSet select:[:aFilename |
-	    (dir construct:aFilename) isDirectory
-	].
+        matchSet := matchSet select:[:aFilename |
+            (dir construct:aFilename) isDirectory
+        ].
     ] ifFalse:[
-	filesOnly ifTrue:[
-	    matchSet := matchSet select:[:aFilename |
-		(dir construct:aFilename) isDirectory not
-	    ].
-	]
+        filesOnly ifTrue:[
+            matchSet := matchSet select:[:aFilename |
+                (dir construct:aFilename) isDirectory not
+            ].
+        ]
     ].
 
     (nMatch := matchSet size) ~~ 1 ifTrue:[
-	"
-	 more than one possible completion -
-	"
-	aBlock value:f
+        "
+         more than one possible completion -
+        "
+        aBlock value:f
     ].
     "
      even with more than one possible completion,
@@ -505,18 +512,18 @@
     "
     name := f asString.
     nMatch == 1 ifTrue:[
-	"
-	 exactly one possible completion -
-	"
-	f := dir construct:matchSet first.
+        "
+         exactly one possible completion -
+        "
+        f := dir construct:matchSet first.
 
-	directoriesOnly ifFalse:[
-	    f isDirectory ifTrue:[
-		(name endsWith:(Filename separator)) ifFalse:[
-		    name := name , '/'
-		].
-	    ].
-	]
+        directoriesOnly ifFalse:[
+            f isDirectory ifTrue:[
+                (name endsWith:(Filename separator)) ifFalse:[
+                    name := name , '/'
+                ].
+            ].
+        ]
     ].
 
     "
@@ -525,21 +532,23 @@
     "
     s := ''.
     1 to:(words size - 1) do:[:idx |
-	s := s , (words at:idx) , ' '
+        s := s , (words at:idx) , ' '
     ].
     s := s , name.
 
     "/ special: if there was no change, and the string represented
     "/ is a directories name, add a directory separator
     s = aString ifTrue:[
-	(s endsWith:Filename separator) ifFalse:[
-	    s asFilename isDirectory ifTrue:[
-		^ s , Filename separator asString
-	    ]
-	]
+        (s endsWith:Filename separator) ifFalse:[
+            s asFilename isDirectory ifTrue:[
+                ^ s , Filename separator asString
+            ]
+        ]
     ].
 
     ^ s
+
+    "Modified: 30.4.1996 / 12:13:20 / cg"
 !
 
 isCaseSensitive
@@ -599,7 +608,7 @@
 suffixSeparator
     "return the filename suffix separator.
      Usually, this is $. for unix-like and msdos systems 
-     (there is currently no knowns system, where this differs)"
+     (there is currently no known system, where this differs)"
 
      ^ $.
 
@@ -608,6 +617,7 @@
      "
 
     "Modified: 7.9.1995 / 11:10:43 / claus"
+    "Modified: 30.4.1996 / 12:14:25 / cg"
 !
 
 volumes
@@ -1907,5 +1917,5 @@
 !Filename class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.57 1996-04-27 18:11:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.58 1996-04-30 10:18:03 cg Exp $'
 ! !