Hi all,

I've recently noticed that sqlite doesn't work on windows 98 since version 3.7.12, due to the change to use OVERLAPPED when read and write files. I've made a small modification to take care of it, and avoid to use that way on win 98 (by using the function isNT() to check that condition). I've attached a patch in this message.

I've tested it and it seems to work fine (tested on win98, xp and win7), but I'd like to know if it's correct or if there is any problem which I can't see.

TIA,

Jose F. Gimenez
--- C:/sqlite/src/os_win.c      Wed Jan 09 14:51:47 2013
+++ C:/sqlite/src/os_win2.c     Wed Jan 09 20:14:47 2013
@@ -2120,10 +2120,16 @@
   }
   while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
 #else
-  memset(&overlapped, 0, sizeof(OVERLAPPED));
-  overlapped.Offset = (LONG)(offset & 0xffffffff);
-  overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
-  while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&
+  if( isNT() ){
+    memset(&overlapped, 0, sizeof(OVERLAPPED));
+    overlapped.Offset = (LONG)(offset & 0xffffffff);
+    overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
+  }else{
+    if( seekWinFile(pFile, offset) ){
+      return SQLITE_FULL;
+    }
+  }
+  while( !osReadFile(pFile->h, pBuf, amt, &nRead, isNT() ? &overlapped : 0) &&
          osGetLastError()!=ERROR_HANDLE_EOF ){
 #endif
     DWORD lastErrno;
@@ -2165,10 +2171,12 @@
 
 #if SQLITE_OS_WINCE
   rc = seekWinFile(pFile, offset);
-  if( rc==0 ){
-#else
-  {
+#else
+  if( !isNT() ){
+    rc = seekWinFile(pFile, offset);
+  }
 #endif
+  if( rc==0 ){
 #if !SQLITE_OS_WINCE
     OVERLAPPED overlapped;        /* The offset for WriteFile. */
 #endif
@@ -2187,7 +2195,7 @@
 #if SQLITE_OS_WINCE
       if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
 #else
-      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
+      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, isNT() ? &overlapped : 
0) ){
 #endif
         if( retryIoerr(&nRetry, &lastErrno) ) continue;
         break;
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to