--- a/Win32OperatingSystem.st Tue Dec 18 19:49:58 2001 +0100
+++ b/Win32OperatingSystem.st Tue Dec 18 20:51:16 2001 +0100
@@ -8532,7 +8532,7 @@
!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.105 2001-12-18 18:49:58 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.106 2001-12-18 19:51:16 cg Exp $'
! !
!Win32OperatingSystem::Win32FILEHandle methodsFor:'release'!
@@ -8559,7 +8559,7 @@
!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.105 2001-12-18 18:49:58 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.106 2001-12-18 19:51:16 cg Exp $'
! !
!Win32OperatingSystem::Win32Handle methodsFor:'io'!
@@ -8637,7 +8637,12 @@
extPtr = extPtr + offs;
}
- ok = ReadFile(hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */);
+ do {
+ __threadErrno = 0;
+ // ok = ReadFile(hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */);
+ ok = __STX_API_CALL5( "ReadFile", ReadFile, hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */);
+ } while(__threadErrno == EINTR);
+
if (ok == TRUE) {
if (! bufferIsExternalBytes) {
/* copy over */
@@ -8672,6 +8677,71 @@
"
!
+readWaitWithTimeoutMs:millis
+ "return true if a timeout occurred"
+
+ |errSym errorNumber|
+
+%{
+ HANDLE hFile = (HANDLE)(__externalAddressVal(self));
+ DWORD res;
+ INT t;
+
+ if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
+ errSym = @symbol(errorNotOpen);
+ goto bad;
+ }
+
+#if 0
+ if (ioctlsocket((SOCKET)hFile, FIONREAD, &res)==0) {
+ /* its a socket */
+ if (res > 0) {
+ RETURN ( false );
+ }
+ }
+ if (PeekNamedPipe(hFile, 0, 0, 0, &res, 0)) {
+ /* its a namedPipe */
+ if (res > 0) {
+ RETURN ( false );
+ }
+ }
+#endif
+ if (__isSmallInteger(millis)) {
+ t = __intVal(millis);
+ } else {
+ t = INFINITE;
+ }
+
+ do {
+ __threadErrno = 0;
+ res = WaitForSingleObject(hFile, t);
+ } while (__threadErrno == EINTR);
+
+ switch (res) {
+ case WAIT_OBJECT_0:
+ /* signalled */
+ RETURN ( false );
+
+ case WAIT_TIMEOUT:
+ /* signalled */
+ RETURN ( true );
+
+ default:
+ case WAIT_ABANDONED:
+ errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
+ goto bad;
+ }
+
+bad: ;
+%}.
+ "
+ timeout argument not integer,
+ or any fd-array nonNil and not an array
+ or not supported by OS
+ "
+ ^ self primitiveFailed
+!
+
seekTo:newPosition from:whence
"whence is one of:
#begin
@@ -8829,6 +8899,6 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.105 2001-12-18 18:49:58 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.106 2001-12-18 19:51:16 cg Exp $'
! !
Win32OperatingSystem initialize!