AbstractOperatingSystem.st
branchjv
changeset 20727 fb8c5591428b
parent 20578 39641ba8d6e0
parent 20666 2f64cdfb78cb
child 20728 83c74234945e
--- a/AbstractOperatingSystem.st	Wed Oct 12 07:05:13 2016 +0200
+++ b/AbstractOperatingSystem.st	Tue Oct 25 12:31:42 2016 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1988 by Claus Gittinger
 	      All Rights Reserved
@@ -2067,6 +2065,75 @@
     "Created: / 10.11.1998 / 20:51:11 / cg"
 !
 
+executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream inDirectory:dir showWindow:showWindow onError:aBlock
+    "execute the unix command specified by the argument, aCommandString.
+     If aCommandString is a String, the commandString is passed to a shell for execution
+     - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
+     If aCommandString is an Array, the first element is the command to be executed,
+     and the other elements are the arguments to the command. No shell is invoked in this case.
+     Return true if successful, the value from aBlock if not.
+     If not successfull, aBlock is called with an OsProcessStatus
+     (containing the exit status) as argument."
+
+    ^ self
+        executeCommand:aCommandString
+        inputFrom:anInStream
+        outputTo:anOutStream
+        errorTo:anErrStream
+        auxFrom:nil
+        environment:nil
+        inDirectory:dir
+        lineWise:false
+        showWindow:showWindow
+        onError:aBlock
+
+    "
+        OperatingSystem
+            executeCommand:'dir'
+            inputFrom:nil
+            outputTo:nil
+            errorTo:nil
+            onError:[:status | Transcript flash]
+
+        OperatingSystem
+            executeCommand:'foo'
+            inputFrom:nil
+            outputTo:nil
+            errorTo:nil
+            onError:[:status | Transcript flash]
+    "
+    "
+        |outStr errStr|
+
+        outStr := '' writeStream.
+        errStr := '' writeStream.
+        OperatingSystem
+            executeCommand:'ls'
+            inputFrom:nil
+            outputTo:outStr
+            errorTo:errStr
+            onError:[:status | Transcript flash].
+        Transcript show:'out:'; showCR:outStr contents.
+        Transcript show:'err:'; showCR:errStr contents.
+    "
+    "
+        |outStr errStr|
+
+        outStr := '' writeStream.
+        errStr := '' writeStream.
+        OperatingSystem
+            executeCommand:'ls /fooBar'
+            inputFrom:nil
+            outputTo:outStr
+            errorTo:errStr
+            onError:[:status | Transcript flash].
+        Transcript show:'out:'; showCR:outStr contents.
+        Transcript show:'err:'; showCR:errStr contents.
+    "
+
+    "Modified: / 10.11.1998 / 20:51:39 / cg"
+!
+
 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream onError:aBlock
     "execute the unix command specified by the argument, aCommandString.
      If aCommandString is a String, the commandString is passed to a shell for execution
@@ -3296,15 +3363,15 @@
 !
 
 getObjectFileInfoFor: aStringOrFilename
-    "Return and info object for given executable or shared object
+    "Return an info object for a given executable or shared object
      or throw an error if given file is not a valid an executable now
      shared object.
 
      The info object returned is OS-specific, however it responds to at
      least
-	#isFor32BitArchitecture
-	#isFor64BitArchitecture ... returns true, if the given object is for
-				     32bit, 64bit architecture respectively
+        #isFor32BitArchitecture
+        #isFor64BitArchitecture ... returns true, if the given object is for
+                                     32bit, 64bit architecture respectively
     "
     ^ self subclassResponsibility
 
@@ -3740,7 +3807,7 @@
 enableIOInterruptsOn:fd
     "turn on IO interrupts for a filedescriptor"
 
-    self subclassResonsibility
+    self subclassResponsibility
 !
 
 enableQuitInterrupts
@@ -3768,7 +3835,7 @@
 enableTimer:milliSeconds
     "setup for a timerInterrupt, to be signalled after some (real) time."
 
-    self subclassResonsibility
+    self subclassResponsibility
 !
 
 enableUserInterrupts
@@ -4132,64 +4199,32 @@
 !AbstractOperatingSystem class methodsFor:'os queries'!
 
 getCCDefine
+    <resource: #obsolete>
+    
     "return a string which was used to identify the C-Compiler used
      when STX was compiled, and which should be passed down when compiling methods.
      For example, on linux, this is '__GNUC__';
-     on windows, this is either '__MSC__' or '__BORLANDC__'"
-
-%{  /* NOCONTEXT */
-#ifndef CC_DEFINE
-# ifdef __win32__
-#  if defined( __BORLANDC__ )
-#   define CC_DEFINE    "__BORLANDC__"
-#  else
-#   if defined( __VISUALC__ )
-#    define CC_DEFINE     "__VISUALC__"
-#   else
-#    if defined( __MINGW64__ )
-#     define CC_DEFINE     "__MINGW64__"
-#    else
-#     if defined( __MINGW32__ )
-#      define CC_DEFINE     "__MINGW32__"
-#     else
-#      define CC_DEFINE     "__CC__"
-#     endif
-#    endif
-#   endif
-#  endif
-# else /* not __win32__ */
-#  ifdef __CLANG__
-#   define CC_DEFINE     "__CLANG__"
-#  else
-#   ifdef __GNUC__
-#    define CC_DEFINE     "__GNUC__"
-#   else
-#    define CC_DEFINE     "__CC__"
-#   endif
-#  endif
-# endif
-#endif
-    RETURN ( __MKSTRING(CC_DEFINE));
-%}
+     on windows, this could be '__VISUALC__', '__BORLANDC__' or '__MINGW__'"
+
+    self obsoleteMethodWarning.
+    ^ STCCompilerInterface getCCDefine
+
     "
      OperatingSystem getCCDefine
     "
 !
 
 getCPUDefine
+    <resource: #obsolete>
     "return a string which was used to identify this CPU type when STX was
      compiled, and which should be passed down when compiling methods.
-     For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'.
+     For example, on linux, this may be '-D__x86__'; on a vax, this would be '-D__vax__'.
      This is normally not of interest to 'normal' users; however, it is passed
      down to the c-compiler when methods are incrementally compiled to machine code."
 
-%{  /* NOCONTEXT */
-#   ifndef CPU_DEFINE
-#       define CPU_DEFINE "-DunknownCPU"
-#   endif
-
-    RETURN ( __MKSTRING(CPU_DEFINE));
-%}
+    self obsoleteMethodWarning.
+    ^ STCCompilerInterface getCPUDefine
+
     "
      OperatingSystem getCPUDefine
     "
@@ -4412,26 +4447,15 @@
 !
 
 getOSDefine
+    <resource: #obsolete>
+    
     "return a string which was used to identify this machine when stx was
      compiled, and which should be passed down when compiling methods.
-     For example, on linux, this is '-DLINUX'."
-
-%{  /* NOCONTEXT */
-
-#ifndef OS_DEFINE
-# ifdef __win32__
-#  define OS_DEFINE "-D__win32__"
-# endif
-
-# ifndef OS_DEFINE
-#  define OS_DEFINE "-DunknownOS"
-# endif
-#endif
-
-    RETURN ( __MKSTRING(OS_DEFINE));
-
-#undef OS_DEFINE
-%}
+     For example, on linux, this is '-D__linux__'."
+
+    self obsoleteMethodWarning.
+    ^ STCCompilerInterface getOSDefine
+
     "
      OperatingSystem getOSDefine
     "
@@ -4593,6 +4617,8 @@
 !
 
 getPlatformDefine
+    <resource: #obsolete>
+    
     "return a string which defines the platform,
      and which should be passed down when compiling methods.
      For example, on all unices, this is '-DUNIX'."
@@ -5117,9 +5143,12 @@
 
 decodePathOrCommandOutput:encodedPathNameOrOutputLine
     "decode the encodedPathNameOrOutputLine as returned by system calls or output by system commands.
+     This takes care for any specific OS encodings or specific command encodings.
+
      E.g. linux system calls return single byte strings only,
      so pathNames have been UTF-8 encoded."
 
+    "/ fallback here: no encoding
     ^ encodedPathNameOrOutputLine
 !