#QUALITY by stefan
authorStefan Vogel <sv@exept.de>
Tue, 29 Nov 2016 12:21:35 +0100
changeset 21062 f2caa5a7f711
parent 21061 9b88e6d3ff58
child 21063 c8d889d18280
#QUALITY by stefan class: AbstractOperatingSystem comment/format in: #createDirectory: changed: #recursiveCreateDirectory: changed error handling from returning false to OSErrorHolder
AbstractOperatingSystem.st
--- a/AbstractOperatingSystem.st	Tue Nov 29 12:20:19 2016 +0100
+++ b/AbstractOperatingSystem.st	Tue Nov 29 12:21:35 2016 +0100
@@ -3039,7 +3039,7 @@
 createDirectory:aPathName
     "create a new directory with name 'aPathName', which may be an absolute
      path, or relative to the current directory.
-     Return true if successful (or the directory existed already), false if failed.
+     Return nil if successful (or the directory existed already), an OsErrorHolder otherwise.
      This is a low-level entry - use Filename protocol for compatibility."
 
     self subclassResponsibility
@@ -3150,20 +3150,28 @@
 
 recursiveCreateDirectory:dirName
     "create a directory - with all parent dirs if needed.
-     Return true if successful, false otherwise. If false
-     is returned, a partial created tree may be left,
-     which is not cleaned-up here."
+     Return nil if successful, an OsErrorHolder otherwise.
+     On error, a partial created tree may be left, which is not cleaned-up here."
+
+    |osErrorHolder nextDirName|
 
     self createDirectory:dirName.
     (self isDirectory:dirName) ifFalse:[
-	(self recursiveCreateDirectory:(dirName asFilename directoryName)) ifFalse:[^ false].
-	^ self createDirectory:dirName
+        nextDirName := dirName asFilename directoryName.
+        dirName ~= nextDirName ifTrue:[
+            osErrorHolder := self recursiveCreateDirectory:nextDirName.
+            osErrorHolder notNil ifTrue:[ 
+                ^ osErrorHolder.
+            ].
+        ].
+        ^ self createDirectory:dirName.
     ].
-    ^ true
+    ^ nil.
 
     "
      OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
      OperatingSystem recursiveRemoveDirectory:'foo'
+     OperatingSystem recursiveCreateDirectory:'k:\bla\quark'
     "
 
     "Modified: 7.3.1996 / 15:26:22 / cg"