UMASK in createDirectory
authorClaus Gittinger <cg@exept.de>
Fri, 13 Feb 2009 14:08:50 +0100
changeset 11535 3a3ef7112002
parent 11534 feb71ed68875
child 11536 d883525654f1
UMASK in createDirectory
UnixOperatingSystem.st
--- a/UnixOperatingSystem.st	Fri Feb 13 12:40:39 2009 +0100
+++ b/UnixOperatingSystem.st	Fri Feb 13 14:08:50 2009 +0100
@@ -1055,6 +1055,7 @@
     "Modified: / 11.12.1998 / 16:22:48 / cg"
 ! !
 
+
 !UnixOperatingSystem class methodsFor:'OS signal constants'!
 
 sigABRT
@@ -3444,22 +3445,39 @@
      Return true if successful (or the directory existed already), false if failed.
      This is a low-level entry - use Filename protocol for compatibility."
 
-    "/ if it already exists this is ok
-
-    (self isDirectory:aPathName) ifTrue:[^ true].
+    ^ self createDirectory:aPathName withAccess:((self getEnvironment:'UMASK') ? 8r0755)
+
+    "
+     OperatingSystem createDirectory:'foo'
+    "
+
+    "Modified: 20.12.1995 / 11:24:13 / stefan"
+    "Modified: 29.6.1996 / 14:06:54 / cg"
+!
+
+createDirectory:aPathName withAccess:umask
+    "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.
+     This is a low-level entry - use Filename protocol for compatibility."
 
 %{
     if (__isString(aPathName)) {
-	int ret;
-
-	ret = mkdir(__stringVal(aPathName), 0755);
-	if (ret < 0) {
-	    @global(LastErrorNumber) = __mkSmallInteger(errno);
-	    RETURN (false);
-	}
-	RETURN (true);
-      }
-%}.
+        if (__isSmallInteger(umask)) {
+            int ret;
+
+            ret = mkdir(__stringVal(aPathName), __intVal(umask));
+            if (ret >= 0) {
+                RETURN(true);
+            }
+            @global(LastErrorNumber) = __mkSmallInteger(errno);
+        }
+    }
+%}.
+    "/ if it already existed this is ok
+
+    (self isDirectory:aPathName) ifTrue:[^ true].
+
 
 "/    self isUNIXlike ifTrue:[
 "/      ^ self executeCommand:('mkdir 2>/dev/null ', newPathName)
@@ -3471,9 +3489,6 @@
     "
      OperatingSystem createDirectory:'foo'
     "
-
-    "Modified: 20.12.1995 / 11:24:13 / stefan"
-    "Modified: 29.6.1996 / 14:06:54 / cg"
 !
 
 createFileForReadAppend:pathName
@@ -12686,7 +12701,7 @@
 !UnixOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.251 2008-11-24 17:34:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.252 2009-02-13 13:08:50 cg Exp $'
 ! !
 
 UnixOperatingSystem initialize!