AbstractOperatingSystem.st
branchjv
changeset 21088 6f4535127ce6
parent 21042 edb2e7f82c62
parent 21068 5f3fa6858dea
child 21249 86c01ee5a76e
--- a/AbstractOperatingSystem.st	Wed Nov 30 10:19:49 2016 +0000
+++ b/AbstractOperatingSystem.st	Wed Nov 30 10:25:34 2016 +0000
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1988 by Claus Gittinger
 	      All Rights Reserved
@@ -771,6 +773,7 @@
 !
 
 errorHolderForNumber:anInteger
+    "return an osErrorHolder for the given error number (as returned by a system call)."
 
     ^ self subclassResponsibility
 !
@@ -3038,7 +3041,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
@@ -3056,12 +3059,12 @@
 
 createHardLinkFrom:oldPath to:newPath
     "link the file 'oldPath' to 'newPath'. The link will be a hard link.
-     Return true if successful, false if not."
+     Return nil if successful, an OsErrorHolder if not."
 
     "/
     "/ assume that this OperatingSystem does not support links
     "/
-    ^ self unsupportedOperationSignal raise
+    ^ OSErrorHolder unsupportedOperation
 
     "Created: / 13.8.1998 / 21:37:12 / cg"
     "Modified: / 13.8.1998 / 21:38:39 / cg"
@@ -3070,12 +3073,12 @@
 createSymbolicLinkFrom:oldPath to:newPath
     "make a link from the file 'oldPath' to the file 'newPath'.
      The link will be a soft (symbolic) link.
-     Return true if successful, false if not."
+     Return nil if successful, an OsErrorHolder if not."
 
     "/
     "/ assume that this OperatingSystem does not support symbolic links
     "/
-    ^ self unsupportedOperationSignal raise
+    ^ OSErrorHolder unsupportedOperation
 
     "Created: / 13.8.1998 / 21:38:24 / cg"
     "Modified: / 13.8.1998 / 21:38:43 / cg"
@@ -3149,20 +3152,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"
@@ -3192,14 +3203,14 @@
 removeDirectory:fullPathName
     "remove the directory named 'fullPathName'.
      The directory must be empty and you must have appropriate access rights.
-     Return true if successful, false if directory is not empty or no permission.
+     return nil if successful, an OSErrorHolder if directory is not empty or no permission.
      This is a lowLevel entry - use Filename protocol for compatibility."
 
     self subclassResponsibility
 !
 
 removeFile:fullPathName
-    "remove the file named 'fullPathName'; return true if successful.
+    "remove the file named 'fullPathName'; return nil if successful, an OSErrorHolder on errror.
      This is a lowLevel entry - use Filename protocol for compatibility."
 
     self subclassResponsibility
@@ -3211,7 +3222,7 @@
      correct for the OS used - therefore, this should not be called
      directlt. Instead, use Filename protocol to rename; this cares for
      any invalid names.
-     Returns true if successful, false if not"
+     Returns nil if successful, an OsErrorHolder if not"
 
     self subclassResponsibility
 !
@@ -3228,7 +3239,7 @@
 !
 
 truncateFile:aPathName to:newSize
-    "change a files size return true on success, false on failure.
+    "change a files size return nil on success, an OSErrorHolder on failure.
      This may not be supported on all architectures.
 
      This is a low-level entry - use Filename protocol."
@@ -3279,8 +3290,8 @@
 changeAccessModeOf:aPathName to:modeBits
     "change the access rights of aPathName to the OS dependent modeBits.
      You should construct this mask using accessMaskFor, to be OS
-     independent. Return true if changed,
-     false if such a file does not exist or change was not allowd."
+     independent. Return nil if changed,
+     anOSErrorHolder if such a file does not exist or change was not allowd."
 
     self subclassResponsibility
 !