ExternalStream.st
branchjv
changeset 18027 3621469cc5e8
parent 18026 fa8a879502cb
parent 14774 788d94977e4e
child 18028 e39da2aa21bc
--- a/ExternalStream.st	Thu Feb 07 09:53:25 2013 +0100
+++ b/ExternalStream.st	Tue Mar 05 18:10:13 2013 +0000
@@ -3017,6 +3017,8 @@
 sync
     "make sure, that the OS writes cached data to the disk"
 
+    self flush.
+
 %{
 #if !defined(__openVMS__)
     FILEPOINTER f;
@@ -3028,29 +3030,29 @@
      || (__INST(handleType) == @symbol(filePointer))
      || (__INST(handleType) == @symbol(socketFilePointer))
      || (__INST(handleType) == @symbol(pipeFilePointer))) {
-	if ((fp = __INST(handle)) != nil) {
-	    f = __FILEVal(fp);
+        if ((fp = __INST(handle)) != nil) {
+            f = __FILEVal(fp);
 #ifdef WIN32
-	    __threadErrno = 0;
-	    ret = __STX_API_NOINT_CALL1( "FlushFileBuffers", FlushFileBuffers, _get_osfhandle(fileno(f)));
-	    if (ret) {
-		RETURN (self);
-	    }
+            __threadErrno = 0;
+            ret = __STX_API_NOINT_CALL1( "FlushFileBuffers", FlushFileBuffers, _get_osfhandle(fileno(f)));
+            if (ret) {
+                RETURN (self);
+            }
 #else
 
-	    __BEGIN_INTERRUPTABLE__
-	    do {
-		__threadErrno = 0;
-		ret = fsync(fileno(f));
-	    } while ((ret < 0) && (__threadErrno == EINTR));
-	    __END_INTERRUPTABLE__
-
-	    if (ret >= 0) {
-		RETURN (self);
-	    }
+            __BEGIN_INTERRUPTABLE__
+            do {
+                __threadErrno = 0;
+                ret = fsync(fileno(f));
+            } while ((ret < 0) && (__threadErrno == EINTR));
+            __END_INTERRUPTABLE__
+
+            if (ret >= 0) {
+                RETURN (self);
+            }
 #endif /* ! WIN32 */
-	    __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
-	}
+            __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
+        }
     }
 #endif /* ! __openVMS__ */
 %}.
@@ -3058,9 +3060,9 @@
     handle isNil ifTrue:[^ self errorNotOpen].
 
     "
-	|f|
-	f := 'x' asFilename writeStream.
-	f nextPutAll:'hallo'; sync; syncData; close
+        |f|
+        f := 'x' asFilename writeStream.
+        f nextPutAll:'hallo'; sync; syncData; close
     "
 !
 
@@ -3070,6 +3072,8 @@
      required to read the file's data (so metadata will not be written,
      if only access/modification time has changed)."
 
+    self flush.
+
 %{
 #if defined(HAS_FDATASYNC)
     int ret;
@@ -5731,11 +5735,11 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.359 2013-02-06 16:02:24 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.360 2013-02-08 16:57:45 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.359 2013-02-06 16:02:24 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.360 2013-02-08 16:57:45 stefan Exp $'
 ! !