UnboundedExternalStream.st
changeset 158 be947d4e7fb2
child 216 a8abff749575
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UnboundedExternalStream.st	Mon Oct 10 01:29:01 1994 +0100
@@ -0,0 +1,112 @@
+"
+ COPYRIGHT (c) 1994 by Claus Gittinger
+	      All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+
+ExternalStream subclass:#UnboundedExternalStream
+       instanceVariableNames:''
+       classVariableNames:''
+       poolDictionaries:''
+       category:'Streams-External'
+!
+
+UnboundedExternalStream comment:'
+COPYRIGHT (c) 1994 by Claus Gittinger
+	      All Rights Reserved
+
+$Header: /cvs/stx/stx/libbasic/UnboundedExternalStream.st,v 1.1 1994-10-10 00:29:01 claus Exp $
+'!
+
+%{
+#include <stdio.h>
+%}
+
+!UnboundedExternalStream class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1994 by Claus Gittinger
+	      All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libbasic/UnboundedExternalStream.st,v 1.1 1994-10-10 00:29:01 claus Exp $
+"
+!
+
+documentation
+"
+    This class provides common protocol for all external streams which are
+    unbound in size (i.e. have no end). Examples of these are PipeStream,
+    Sockets, TTYStreams etc.
+"
+! !
+
+!UnboundedExternalStream methodsFor:'testing'!
+
+atEnd
+    "return true, if position is at end"
+
+%{  /* NOCONTEXT */
+    FILE *f;
+    OBJ t;
+    OBJ _true = true;
+    int c;
+
+    if (_INST(hitEOF) == _true) {
+	RETURN (_true);
+    }
+    /*
+     * has to be redefined, since EOF is never really
+     * reached (although stdio library thinks so ...)
+     */
+    if ((t = _INST(filePointer)) != nil) {
+	f = MKFD(t);
+	if (feof(f)) {
+	    if (ferror(f)) {
+		_INST(hitEOF) = true;
+		RETURN (true);
+	    }
+	}
+	RETURN ( false );
+    }
+%}.
+    ^ self errorNotOpen
+! !
+
+!UnboundedExternalStream methodsFor:'redefind basic'!
+
+size
+    "report an error that this stream has no concept of size"
+
+    self shouldNotImplement
+!
+
+position
+    "report an error that this stream has no concept of position"
+
+    self shouldNotImplement
+!
+
+position:anInteger
+    "report an error that this stream has no concept of position"
+
+    self shouldNotImplement
+! !
+