#REFACTORING by stefan
authorStefan Vogel <sv@exept.de>
Tue, 03 Mar 2020 16:23:05 +0100
changeset 25314 a91d744724d0
parent 25313 a91253d9c944
child 25315 8227a9ce831d
#REFACTORING by stefan class: ExternalStream changed: #blocking: #fileDescriptor
ExternalStream.st
--- a/ExternalStream.st	Tue Mar 03 16:20:40 2020 +0100
+++ b/ExternalStream.st	Tue Mar 03 16:23:05 2020 +0100
@@ -2190,39 +2190,36 @@
      notice: this one returns the underlying OSs fileDescriptor -
      this may not be available on all platforms (i.e. non unix systems)."
 
-    |fileClosed|
-
 %{
     OBJ _handle  = __INST(handle);
 
-    fileClosed = false;
     if (_handle != nil) {
-	if ((__INST(handleType) == @symbol(fileHandle))
-	 || (__INST(handleType) == @symbol(socketHandle))) {
-	    RETURN (_handle);
-	}
-
-	if ((__INST(handleType) == nil)
-	 || (__INST(handleType) == @symbol(filePointer))
-	 || (__INST(handleType) == @symbol(socketFilePointer))
-	 || (__INST(handleType) == @symbol(pipeFilePointer))) {
-	    FILE *file = __FILEVal(_handle);
-	    if (file != NULL) {
-		int fileNo = fileno(file);
-
-		if (fileNo >= 0) {
-		    RETURN ( __MKINT(fileNo));
-		}
-		fileClosed = true;
-	    }
-	}
+        if ((__INST(handleType) == @symbol(fileHandle))
+         || (__INST(handleType) == @symbol(socketHandle))) {
+            RETURN (_handle);
+        }
+
+        if ((__INST(handleType) == nil)
+         || (__INST(handleType) == @symbol(filePointer))
+         || (__INST(handleType) == @symbol(socketFilePointer))
+         || (__INST(handleType) == @symbol(pipeFilePointer))) {
+            FILE *file = __FILEVal(_handle);
+            if (file != NULL) {
+                int fileNo = fileno(file);
+
+                if (fileNo >= 0) {
+                    RETURN ( __MKINT(fileNo));
+                }
+            }
+            __INST(handle) = nil;
+        }
     }
 %}.
     handle isNil ifTrue:[^ self errorNotOpen].
-    fileClosed ifTrue:[handle := nil. ^ self errorNotOpen].
     ^ self fileDescriptorOfFile:handle
 
     "Modified: / 05-05-2017 / 16:27:34 / cg"
+    "Modified: / 03-03-2020 / 15:50:27 / Stefan Vogel"
 !
 
 fileDescriptorOfFile:aHandle
@@ -3134,12 +3131,16 @@
     |fd|
 
     fd := self fileDescriptor.
-    "self fileDescriptor may set handle to nil"
-    handle isNil ifTrue:[^ self errorNotOpen].
-    ^ OperatingSystem setBlocking:aBoolean on:fd.
-
-    "Modified: / 11.1.1997 / 17:48:01 / cg"
-    "Modified: / 15.1.1998 / 11:49:48 / stefan"
+    "self fileDescriptor may set handle to nil
+     and does 'self errorNotOpen' if handle is nil"
+    handle notNil ifTrue:[
+        ^ OperatingSystem setBlocking:aBoolean on:fd.
+    ]. 
+    ^ true.
+
+    "Modified: / 11-01-1997 / 17:48:01 / cg"
+    "Modified: / 15-01-1998 / 11:49:48 / stefan"
+    "Modified: / 03-03-2020 / 15:43:55 / Stefan Vogel"
 !
 
 ioctl:ioctlNumber