Filename.st
changeset 85 1343af456e28
parent 77 6c38ca59927f
child 88 81dacba7a63a
--- a/Filename.st	Thu Jun 02 13:20:08 1994 +0200
+++ b/Filename.st	Thu Jun 02 13:21:56 1994 +0200
@@ -24,7 +24,7 @@
 Filenames; originally added for ST-80 compatibility, is
 taking over functionality from other classes (FileDirectory).
 
-$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.8 1994-05-17 10:07:34 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.9 1994-06-02 11:20:23 claus Exp $
 '!
 
 !Filename class methodsFor:'instance creation'!
@@ -62,9 +62,17 @@
      filename for an entry within this directory (i.e. for a file
      or a subdirectory in that directory)."
 
+    nameString = self class separator asString ifTrue:[
+        "I am the root"
+        ^ (self class basicNew) setName:(nameString  , subname)
+    ].
     ^ (self class basicNew) setName:(nameString , self class separator asString , subname)
 
-    "('/tmp' asFilename construct:'foo') asString"
+    "
+     ('/tmp' asFilename construct:'foo') asString    
+     ('/' asFilename construct:'foo') asString         
+     ('/usr/tmp' asFilename construct:'foo') asString
+    "
 ! !
 
 !Filename methodsFor:'converting'!
@@ -107,18 +115,34 @@
 
     ^ OperatingSystem baseNameOf:nameString
 
-    "/foo/bar' asFilename baseName"
+    "
+     /foo/bar' asFilename baseName
+    "
 !
 
 isAbsolute
     "return true, if the receiver represents an absolute pathname
      (in contrast to one relative to the current directory)"
 
-    ^ (nameString startsWith:self separator)
+    ^ (nameString startsWith:self class separator)
+
+    "
+     /foo/bar' asFilename isAbsolute
+     '..' asFilename isAbsolute
+     'source/SBrowser.st' asFilename isAbsolute
+    "
+!
 
-    "/foo/bar' asFilename isAbsolute"
-    "'..' asFilename isAbsolute"
-    "'source/SBrowser.st' asFilename isAbsolute"
+isDirectory
+    "return true, if the receiver represents an existing,
+     readable directories pathname."
+
+    ^ OperatingSystem isDirectory:nameString
+
+    "
+     '/foo/bar' asFilename isDirectory
+     '/tmp' asFilename isDirectory
+    "
 !
 
 exists
@@ -126,8 +150,10 @@
 
     ^ OperatingSystem isValidPath:nameString
 
-    "'/foo/bar' asFilename exists"
-    "'/tmp' asFilename exists"
+    "
+     '/foo/bar' asFilename exists
+     '/tmp' asFilename exists
+    "
 !
 
 isReadable
@@ -135,8 +161,10 @@
 
     ^ OperatingSystem isReadable:nameString
 
-    "'/foo/bar' asFilename isReadable"
-    "'/tmp' asFilename isReadable"
+    "
+     '/foo/bar' asFilename isReadable
+     '/tmp' asFilename isReadable
+    "
 !
 
 isWritable
@@ -144,8 +172,10 @@
 
     ^ OperatingSystem isWritable:nameString
 
-    "'/foo/bar' asFilename isWritable"
-    "'/tmp' asFilename isWritable"
+    "
+     '/foo/bar' asFilename isWritable
+     '/tmp' asFilename isWritable
+    "
 ! !
 
 !Filename methodsFor:'file access'!