ExternalStream.st
changeset 14760 3cd759eef99f
parent 14753 9545fe46a30c
child 14774 788d94977e4e
child 18026 fa8a879502cb
equal deleted inserted replaced
14759:6900d60cac58 14760:3cd759eef99f
  3077     __INST(lastErrorNumber) = nil;
  3077     __INST(lastErrorNumber) = nil;
  3078     if ((__INST(handleType) == nil)
  3078     if ((__INST(handleType) == nil)
  3079      || (__INST(handleType) == @symbol(filePointer))
  3079      || (__INST(handleType) == @symbol(filePointer))
  3080      || (__INST(handleType) == @symbol(socketFilePointer))
  3080      || (__INST(handleType) == @symbol(socketFilePointer))
  3081      || (__INST(handleType) == @symbol(pipeFilePointer))) {
  3081      || (__INST(handleType) == @symbol(pipeFilePointer))) {
  3082 	OBJ fp;
  3082         OBJ fp;
  3083 	FILEPOINTER f;
  3083         FILEPOINTER f;
  3084 
  3084 
  3085 	if ((fp = __INST(handle)) != nil) {
  3085         if ((fp = __INST(handle)) != nil) {
  3086 	    f = __FILEVal(fp);
  3086             f = __FILEVal(fp);
  3087 #ifdef WIN32
  3087 #ifdef WIN32
  3088 	    __threadErrno = 0;
  3088             __threadErrno = 0;
  3089 	    ret = __STX_API_NOINT_CALL1( "FlushFileBuffers", FlushFileBuffers, _get_osfhandle(fileno(f)));
  3089             ret = __STX_API_NOINT_CALL1( "FlushFileBuffers", FlushFileBuffers, _get_osfhandle(fileno(f)));
  3090 	    if (ret) {
  3090             if (ret) {
  3091 		RETURN (self);
  3091                 RETURN (self);
  3092 	    }
  3092             }
  3093 #else
  3093 #else
  3094 
  3094 
  3095 	    __BEGIN_INTERRUPTABLE__
  3095             __BEGIN_INTERRUPTABLE__
  3096 	    do {
  3096             do {
  3097 		__threadErrno = 0;
  3097                 __threadErrno = 0;
  3098 		ret = fdatasync(fileno(f));
  3098                 ret = fdatasync(fileno(f));
  3099 	    } while ((ret < 0) && (__threadErrno == EINTR));
  3099             } while ((ret < 0) && (__threadErrno == EINTR));
  3100 	    __END_INTERRUPTABLE__
  3100             __END_INTERRUPTABLE__
  3101 
  3101 
  3102 	    if (ret >= 0) {
  3102             if (ret >= 0) {
  3103 		RETURN (self);
  3103                 RETURN (self);
  3104 	    }
  3104             }
  3105 #endif /* ! WIN32 */
  3105 #endif /* ! WIN32 */
  3106 	    __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
  3106             __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
  3107 	}
  3107         }
  3108     }
  3108     }
  3109 #endif /* ! __openVMS__ */
  3109 #endif /* ! __openVMS__ */
  3110 %}.
  3110 %}.
  3111     lastErrorNumber notNil ifTrue:[^ self ioError].
  3111     lastErrorNumber notNil ifTrue:[^ self ioError].
  3112     handle isNil ifTrue:[^ self errorNotOpen].
  3112     handle isNil ifTrue:[^ self errorNotOpen].
  3113 
  3113 
       
  3114     "if notdef HAS_DATASYNC, fall back"
       
  3115     self sync.
       
  3116 
  3114     "
  3117     "
  3115 	|f|
  3118         |f|
  3116 	f := 'x' asFilename writeStream.
  3119         f := 'x' asFilename writeStream.
  3117 	f nextPutAll:'hallo'; sync; syncData; close
  3120         f nextPutAll:'hallo'; sync; syncData; close
  3118     "
  3121     "
  3119 !
  3122 !
  3120 
  3123 
  3121 truncateTo:newSize
  3124 truncateTo:newSize
  3122     "truncate the underlying OS file to newSize.
  3125     "truncate the underlying OS file to newSize.
  5726 ! !
  5729 ! !
  5727 
  5730 
  5728 !ExternalStream class methodsFor:'documentation'!
  5731 !ExternalStream class methodsFor:'documentation'!
  5729 
  5732 
  5730 version
  5733 version
  5731     ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.358 2013-02-05 15:31:46 stefan Exp $'
  5734     ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.359 2013-02-06 16:02:24 stefan Exp $'
  5732 !
  5735 !
  5733 
  5736 
  5734 version_CVS
  5737 version_CVS
  5735     ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.358 2013-02-05 15:31:46 stefan Exp $'
  5738     ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.359 2013-02-06 16:02:24 stefan Exp $'
  5736 ! !
  5739 ! !
  5737 
  5740 
  5738 
  5741 
  5739 ExternalStream initialize!
  5742 ExternalStream initialize!