Filename.st
changeset 5595 b80d12c4983b
parent 5594 3d801043be3f
child 5596 4168727b2da4
--- a/Filename.st	Sat Sep 09 16:15:45 2000 +0200
+++ b/Filename.st	Sat Sep 09 17:30:54 2000 +0200
@@ -1767,6 +1767,64 @@
     "Modified: / 5.5.1999 / 13:41:21 / cg"
 !
 
+removeDirectory
+    "remove the directory.
+     Raises an exception if not successful (or if its not a directory).
+     Use #recursiveRemove in order to (recursively) remove non empty directories."
+
+    |ok|
+
+    ok := OperatingSystem removeDirectory:(self osNameForFile).
+    ok ifFalse:[
+        self exists ifFalse:[ ^ self].
+        self removeError:self
+    ].
+
+    "
+     (FileStream newFileNamed:'foo') close.
+     'foo' asFilename removeDirectory   
+    "
+
+    "
+     'foo' asFilename writeStream close.
+     'foo' asFilename removeDirectory   
+    "
+
+    "
+     'foo' asFilename makeDirectory.
+     'foo/bar' asFilename writeStream close.
+     ('foo' asFilename remove) ifFalse:[
+        Transcript showCR:'could not remove foo'
+     ]
+    "
+
+    "Modified: / 20.11.1997 / 17:40:22 / stefan"
+    "Modified: / 5.5.1999 / 13:41:12 / cg"
+!
+
+removeFile
+    "remove the file.
+     Raises an exception if not successful (or if its not a file)."
+
+    |ok|
+
+    ok := OperatingSystem removeFile:(self osNameForFile).
+    ok ifFalse:[
+        self exists ifFalse:[ ^ self].
+        self removeError:self
+    ].
+
+    "
+     (FileStream newFileNamed:'foo') close.
+     'foo' asFilename removeFile   
+    "
+
+    "
+     'foo' asFilename makeDirectory.
+     'foo' asFilename removeFile   
+    "
+!
+
 renameOrCopyTo:newName
     "rename or copy the file - the argument must be convertable to a String.
      Raises an exception if not successful.
@@ -3658,6 +3716,6 @@
 !Filename class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.184 2000-09-09 14:15:45 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.185 2000-09-09 15:30:54 cg Exp $'
 ! !
 Filename initialize!