ExternalStream.st
changeset 7002 7a5d55f87cd7
parent 6812 0c07a6b89041
child 7013 993d318775b7
--- a/ExternalStream.st	Mon Feb 03 13:45:59 2003 +0100
+++ b/ExternalStream.st	Mon Feb 03 13:50:14 2003 +0100
@@ -1575,10 +1575,32 @@
      This may be used to wrap fd's as returned by user 
      primitive code, or to wrap pipe-fds into externalStreams."
 
+    ^ self forFileDescriptor:aFileDescriptor mode:modeString buffered:true
+
+    "
+     the example below will probably fail (15 is a random FD):
+
+     |s|
+
+     s := ExternalStream forFileDescriptor:15 mode:'r'.
+     s next.
+    "
+
+    "Created: 29.2.1996 / 18:05:00 / cg"
+    "Modified: 29.2.1996 / 18:17:07 / cg"
+!
+
+forFileDescriptor:aFileDescriptor mode:modeString buffered:buffered
+    "given a fileDescriptor, create an ExternalStream object
+     to operate on this fd. 
+     The mode-argument is passed to the fdopen call.
+     This may be used to wrap fd's as returned by user 
+     primitive code, or to wrap pipe-fds into externalStreams."
+
     |newStream|
 
     newStream := self basicNew.
-    newStream text; buffered:true; eolMode:DefaultEOLMode; clearEOF.
+    newStream text; buffered:buffered; eolMode:DefaultEOLMode; clearEOF.
     ^ newStream connectTo:aFileDescriptor withMode:modeString
 
     "
@@ -1699,17 +1721,19 @@
      This is the higher level equivalent of OperatingSystem>>makePTYPair
      (which returns an array of file-descriptors)."
 
-     |ptyPair m s|
-
-     ptyPair := OperatingSystem makePTYPair.
-     ptyPair notNil ifTrue:[
-	 m := self forReadWriteToFileDescriptor:(ptyPair at:1).
-	 s := self forReadWriteToFileDescriptor:(ptyPair at:2).
-	 ptyPair at:1 put:m.
-	 ptyPair at:2 put:s.
-	 ^ ptyPair
-     ].
-     ^ nil
+    |ptyPair master slave|
+
+    ptyPair := OperatingSystem makePTYPair.
+    ptyPair notNil ifTrue:[
+        master := self forReadWriteToFileDescriptor:(ptyPair at:1).
+        master buffered:false.
+        slave := self forReadWriteToFileDescriptor:(ptyPair at:2).
+        slave buffered:false.
+        ptyPair at:1 put:master.
+        ptyPair at:2 put:slave.
+        ^ ptyPair
+    ].
+    ^ nil
 
     "
      ExternalStream makePTYPair.
@@ -5771,7 +5795,7 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.244 2002-10-24 15:42:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.245 2003-02-03 12:50:14 penk Exp $'
 ! !
 
 ExternalStream initialize!