#FEATURE by cg
class: ExternalStream
changed:
#fileDescriptor
#fileDescriptorOfFile:
care for FD with error
--- a/ExternalStream.st Wed May 03 15:39:21 2017 +0200
+++ b/ExternalStream.st Fri May 05 16:44:36 2017 +0200
@@ -2156,17 +2156,22 @@
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);
- } else if ((__INST(handleType) == nil)
- || (__INST(handleType) == @symbol(filePointer))
- || (__INST(handleType) == @symbol(socketFilePointer))
- || (__INST(handleType) == @symbol(pipeFilePointer))) {
+ }
+
+ 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);
@@ -2174,17 +2179,19 @@
if (fileNo >= 0) {
RETURN ( __MKINT(fileNo));
}
+ fileClosed = true;
}
}
}
%}.
handle isNil ifTrue:[^ self errorNotOpen].
+ fileClosed ifTrue:[handle := nil. ^ self errorNotOpen].
^ self fileDescriptorOfFile:handle
- "Modified: / 07-04-2017 / 16:43:54 / cg"
-!
-
-fileDescriptorOfFile:handle
+ "Modified: / 05-05-2017 / 16:27:34 / cg"
+!
+
+fileDescriptorOfFile:aHandle
"for migration to rel5 only:
return the fileDescriptor of the argument handle -
notice: this one returns the underlying OSs fileDescriptor -
@@ -2192,10 +2199,12 @@
%{
#ifdef __SCHTEAM__
- return context._RETURN(handle);
+ return context._RETURN(aHandle);
#endif
%}.
- self primitiveFailed
+ ^ nil
+
+ "Modified: / 05-05-2017 / 16:20:20 / cg"
!
fileHandle