ExternalStream.st
changeset 21130 a3a7d6f1a3b8
parent 21097 12cf2700134c
child 21139 eed3da14afff
--- a/ExternalStream.st	Tue Dec 13 11:32:12 2016 +0100
+++ b/ExternalStream.st	Wed Dec 14 16:48:25 2016 +0100
@@ -5139,37 +5139,8 @@
 !
 
 numAvailable
-    "return the number of bytes available for reading"
-
-    |fd|
-
-    handle isNil ifTrue:[^ self errorNotOpen].
-    mode == #writeonly ifTrue:[^ self errorWriteOnly].
-    fd := self fileDescriptor.
-
-%{
-#ifdef __win32__
-    int res = 1;
-    int success = 0;
-
-    if (__INST(handleType) == @symbol(socketHandle)) {
-	success = ioctlsocket((SOCKET)__externalAddressVal(fd), FIONREAD, &res) == 0;
-    } else if (__INST(handleType) == @symbol(socketFilePointer)) {
-	success = ioctlsocket((SOCKET)_get_osfhandle(__intVal(fd)), FIONREAD, &res) == 0;
-    } else if (__INST(handleType) == @symbol(pipeFilePointer)) {
-	success = PeekNamedPipe((HANDLE)_get_osfhandle(__intVal(fd)),0,0,0,&res,0);
-    }
-    if (success) {
-	if (__INST(readAhead) != nil) res++;
-	RETURN(__mkSmallInteger(res));
-    }
-#endif
-%}.
-
-    ^ (readAhead notNil or:[OperatingSystem readCheck:fd]) ifTrue:[1] ifFalse:[0].
-
-    "Created: / 4.2.1998 / 16:56:01 / cg"
-    "Modified: / 4.2.1998 / 17:31:11 / cg"
+    <resource: #obsolete>
+    ^ self numAvailableForRead
 ! !
 
 !ExternalStream methodsFor:'reading'!
@@ -5776,7 +5747,8 @@
     ^ available.
 
     "
-        '/etc/hosts' asFilename readStream bytesAvailable"
+        '/etc/hosts' asFilename readStream numAvailableForRead
+    "
 !
 
 readWaitWithTimeoutMs:timeoutOrNil