Unix.st
changeset 2080 d93d4af439d7
parent 2073 4c2bdfc668c9
child 2098 8790a0a6b214
--- a/Unix.st	Tue Jan 07 17:39:03 1997 +0100
+++ b/Unix.st	Tue Jan 07 21:19:46 1997 +0100
@@ -10,24 +10,26 @@
  hereby transferred.
 "
 
+'From Smalltalk/X, Version:3.1.3 on 7-jan-1997 at 20:04:25'                     !
+
 Object subclass:#OperatingSystem
 	instanceVariableNames:''
-	classVariableNames:'HostName DomainName LastErrorNumber LastExecStatus OSSignals
+	classVariableNames:'HostName DomainName LastErrorNumber OSSignals
 		SlowFork ForkFailed ErrorSignal AccessDeniedErrorSignal
 		FileNotFoundErrorSignal LocaleInfo'
 	poolDictionaries:''
 	category:'System-Support'
 !
 
-Object subclass:#FileStatusInfo
-	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path'
+Object subclass:#OSProcessStatus
+	instanceVariableNames:'pid status code core'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:OperatingSystem
 !
 
-Object subclass:#OSProcessStatus
-	instanceVariableNames:'pid status code core'
+Object subclass:#FileStatusInfo
+	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:OperatingSystem
@@ -818,9 +820,6 @@
 
 	LastErrorNumber <Integer>       the last value of errno
 
-	LastExecStatus  <Integer>       the returned exec status after
-					the last call of system
-
 	OSSignals       <Array>         Array of signals to be raised for corresponding
 					OperatingSystem signals.
 
@@ -957,11 +956,11 @@
 	HostName := nil.
 	DomainName := nil.
 	LastErrorNumber := nil.
-	LastExecStatus := nil
     ]
 
     "Modified: 22.4.1996 / 13:10:43 / cg"
     "Created: 15.6.1996 / 15:22:37 / cg"
+    "Modified: 7.1.1997 / 19:36:11 / stefan"
 ! !
 
 !OperatingSystem class methodsFor:'OS signal constants'!
@@ -2652,18 +2651,6 @@
     "
      OperatingSystem lastErrorSymbol
     "
-!
-
-lastExecStatus
-    "return the last execution status.
-     Notice: having a single error number is a bad idea in a multithreaded
-	     environment - this interface will change."
-
-    ^ LastExecStatus
-
-     "
-      OperatingSystem lastExecStatus
-     "
 ! !
 
 !OperatingSystem class methodsFor:'executing OS commands'!
@@ -2979,35 +2966,35 @@
      'sh -c' in your UNIX manual.
      Return true if successful, false otherwise."
 
-" when all machines have been checked, this will be defined as:
      ^ self executeCommand:aCommandString onError:[:status| false]
-until then:"
-
-%{ 
-    int status;
-
-    if (__isString(aCommandString)) {
-	/*
-	 * ST/X provides a modified (fixed) implementation of the
-	 * system() libc-function, which is interruptable ...
-	 */
-# ifdef WANT_SYSTEM
-	status = mySystem((char *) __stringVal(aCommandString));
-# else
-	status = system((char *) __stringVal(aCommandString));
-# endif
-	OperatingSystem_LastExecStatus = __MKSMALLINT(status);
-	if (status == 0) {
-	    RETURN ( true );
-	}
-	OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
-	RETURN ( false );
-    }
-%}.
-    "/
-    "/ invalid argument (non-string)
-    "/
-    ^ self primitiveFailed
+
+"/Old code:
+"/
+"/%{ 
+"/    int status;
+"/
+"/    if (__isString(aCommandString)) {
+"/        /*
+"/         * ST/X provides a modified (fixed) implementation of the
+"/         * system() libc-function, which is interruptable ...
+"/         */
+"/# ifdef WANT_SYSTEM
+"/        status = mySystem((char *) __stringVal(aCommandString));
+"/# else
+"/        status = system((char *) __stringVal(aCommandString));
+"/# endif
+"/        OperatingSystem_LastExecStatus = __MKSMALLINT(status);
+"/        if (status == 0) {
+"/            RETURN ( true );
+"/        }
+"/        OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
+"/        RETURN ( false );
+"/    }
+"/%}.
+"/    "/
+"/    "/ invalid argument (non-string)
+"/    "/
+"/    ^ self primitiveFailed
 
     "
      OperatingSystem executeCommand:'sleep 30'. 
@@ -3017,7 +3004,7 @@
      OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. 
     "
 
-    "Modified: 27.12.1995 / 23:40:35 / stefan"
+    "Modified: 7.1.1997 / 19:29:55 / stefan"
 !
 
 executeCommand:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream onError:aBlock
@@ -4467,40 +4454,40 @@
     path := self primPathNameOf:pathName.
 
     path isNil ifTrue:[
-        (self isValidPath:pathName) ifFalse:[
-            p := pathName.
-            [(p size > 1)
-             and:[p endsWith:(self fileSeparator)]
-            ] whileTrue:[
-                p := p copyWithoutLast:1.
-            ].
-            ^ p
-        ].
-
-        (SlowFork==true or:[ForkFailed==true]) ifFalse:[
-            PipeStream openErrorSignal handle:[:ex |
-                ForkFailed := true.
-                'OS: cannot fork/popen' errorPrintNL.
-                ex return.
-            ] do:[
-                "have to fall back ..."
-                command := 'cd ' , pathName , '; pwd'.
-                p := PipeStream readingFrom:command.
-            ].
-
-            (p isNil or:[p atEnd]) ifTrue:[
-                ('OS: PipeStream for <' , command , '> failed') errorPrintNL.
-            ] ifFalse:[
-                path := p nextLine.
-                p close.
-            ].
-        ].
-        path isNil ifTrue:[
-            path := pathName
-        ].
-        (SlowFork==true or:[ForkFailed==true]) ifTrue:[
-            path := self compressPath:path
-        ]
+	(self isValidPath:pathName) ifFalse:[
+	    p := pathName.
+	    [(p size > 1)
+	     and:[p endsWith:(self fileSeparator)]
+	    ] whileTrue:[
+		p := p copyWithoutLast:1.
+	    ].
+	    ^ p
+	].
+
+	(SlowFork==true or:[ForkFailed==true]) ifFalse:[
+	    PipeStream openErrorSignal handle:[:ex |
+		ForkFailed := true.
+		'OS: cannot fork/popen' errorPrintNL.
+		ex return.
+	    ] do:[
+		"have to fall back ..."
+		command := 'cd ' , pathName , '; pwd'.
+		p := PipeStream readingFrom:command.
+	    ].
+
+	    (p isNil or:[p atEnd]) ifTrue:[
+		('OS: PipeStream for <' , command , '> failed') errorPrintNL.
+	    ] ifFalse:[
+		path := p nextLine.
+		p close.
+	    ].
+	].
+	path isNil ifTrue:[
+	    path := pathName
+	].
+	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
+	    path := self compressPath:path
+	]
     ].
     ^ path.
 
@@ -8029,96 +8016,6 @@
     ^ false
 ! !
 
-!OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
-
-type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
-    ^ self basicNew
-	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP       
-! !
-
-!OperatingSystem::FileStatusInfo methodsFor:'accessing'!
-
-accessed
-    "return accessed"
-
-    ^ accessed!
-
-gid
-    "return gid"
-
-    ^ gid!
-
-id
-    "return id"
-
-    ^ id!
-
-mode
-    "return mode"
-
-    ^ mode!
-
-modified
-    "return modified"
-
-    ^ modified!
-
-path
-    "for symbolic links only: return the path where the symbolic link points to"
-
-    ^ path
-
-!
-
-size
-    "return size"
-
-    ^ size!
-
-statusChanged
-    "return statusChanged"
-
-    ^ statusChanged!
-
-type
-    "return type"
-
-    ^ type!
-
-uid
-    "return uid"
-
-    ^ uid! !
-
-!OperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
-
-at:key
-    "backward compatibility access: in previous releases, IdentityDictionaries
-     were used to hold my information. Allow access via key messages.
-     This method will vanish - use the proper access protocol."
-
-    ^ self perform:key
-
-
-! !
-
-!OperatingSystem::FileStatusInfo methodsFor:'private accessing'!
-
-type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
-    type := t.
-    mode := m.
-    uid := u.
-    gid := g.
-    size := s.
-    id := i.
-    accessed := aT.
-    modified := mT.
-    statusChanged := sT.
-    path := lP
-
-
-! !
-
 !OperatingSystem::OSProcessStatus class methodsFor:'documentation'!
 
 documentation
@@ -8277,9 +8174,99 @@
     "Modified: 28.12.1995 / 14:13:41 / stefan"
 ! !
 
+!OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
+
+type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
+    ^ self basicNew
+	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP       
+! !
+
+!OperatingSystem::FileStatusInfo methodsFor:'accessing'!
+
+accessed
+    "return accessed"
+
+    ^ accessed!
+
+gid
+    "return gid"
+
+    ^ gid!
+
+id
+    "return id"
+
+    ^ id!
+
+mode
+    "return mode"
+
+    ^ mode!
+
+modified
+    "return modified"
+
+    ^ modified!
+
+path
+    "for symbolic links only: return the path where the symbolic link points to"
+
+    ^ path
+
+!
+
+size
+    "return size"
+
+    ^ size!
+
+statusChanged
+    "return statusChanged"
+
+    ^ statusChanged!
+
+type
+    "return type"
+
+    ^ type!
+
+uid
+    "return uid"
+
+    ^ uid! !
+
+!OperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
+
+at:key
+    "backward compatibility access: in previous releases, IdentityDictionaries
+     were used to hold my information. Allow access via key messages.
+     This method will vanish - use the proper access protocol."
+
+    ^ self perform:key
+
+
+! !
+
+!OperatingSystem::FileStatusInfo methodsFor:'private accessing'!
+
+type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
+    type := t.
+    mode := m.
+    uid := u.
+    gid := g.
+    size := s.
+    id := i.
+    accessed := aT.
+    modified := mT.
+    statusChanged := sT.
+    path := lP
+
+
+! !
+
 !OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.183 1997-01-07 11:08:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.184 1997-01-07 20:19:46 stefan Exp $'
 ! !
 OperatingSystem initialize!