ExternalStream.st
changeset 12674 80fbcc4be1d6
parent 12631 9e55d449f787
child 12678 662465401b77
--- a/ExternalStream.st	Mon Feb 01 12:29:35 2010 +0100
+++ b/ExternalStream.st	Mon Feb 01 19:14:37 2010 +0100
@@ -4225,54 +4225,61 @@
 
 clearEOF
     hitEOF := false
-! !
-
-!ExternalStream protectedMethodsFor:'private'!
+!
 
 closeFile
     "low level close - may be redefined in subclasses
      Don't send this message, send #close instead"
 
-    |fp|
+    |fp error|
 
 %{
     if ((__INST(handleType) == nil)
      || (__INST(handleType) == @symbol(filePointer))
      || (__INST(handleType) == @symbol(socketFilePointer))
      || (__INST(handleType) == @symbol(pipeFilePointer))) {
-	if ((fp = __INST(handle)) != nil) {
-	    FILEPOINTER f;
-	    int rslt;
-
-	    __INST(handle) = nil;
-	    f = __FILEVal(fp);
-	    if (@global(FileOpenTrace) == true) {
-		fprintf(stderr, "fclose [ExternalStream] %x\n", f);
-	    }
+        if ((fp = __INST(handle)) != nil) {
+            FILEPOINTER f;
+            int rslt;
+
+            f = __FILEVal(fp);
+            if (@global(FileOpenTrace) == true) {
+                fprintf(stderr, "fclose [ExternalStream] %x\n", f);
+            }
 #ifdef WIN32
-	    do {
-		__threadErrno = 0;
-		rslt = __STX_C_CALL1("fclose", fclose, f);
-	    } while((rslt < 0) && (__threadErrno == EINTR));
+            do {
+                __threadErrno = 0;
+                rslt = __STX_C_CALL1("fclose", fclose, f);
+            } while((rslt < 0) && (__threadErrno == EINTR));
 #else
-	    __BEGIN_INTERRUPTABLE__
-	    fclose(f);
-	    __END_INTERRUPTABLE__
+            __BEGIN_INTERRUPTABLE__
+            rslt = fclose(f);
+            __END_INTERRUPTABLE__
 #endif
-	}
-	RETURN (self);
+            if (rslt < 0) {
+                error = __mkSmallInteger(__threadErrno);
+                goto out;
+            }
+            __INST(handle) = nil;
+        }
+        RETURN (self);
     }
+out:;
 %}.
+
+    error notNil ifTrue:[
+        self primitiveFailed.
+        ^ self.
+    ].
+
     "/ fallback for rel5
 
     fp := handle.
     fp notNil ifTrue:[
-	handle := nil.
-	self closeFile:fp
+        handle := nil.
+        self closeFile:fp
     ]
-! !
-
-!ExternalStream methodsFor:'private'!
+!
 
 closeFile:handle
     "for rel5 only"
@@ -5624,11 +5631,11 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.331 2009-12-21 15:37:28 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.332 2010-02-01 18:14:37 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.331 2009-12-21 15:37:28 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.332 2010-02-01 18:14:37 stefan Exp $'
 ! !
 
 ExternalStream initialize!