SQLite

Check-in [36efafc618]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use SetFilePointerEx() instead of SetFilePointer() on winRT.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | winrt
Files: files | file ages | folders
SHA1: 36efafc618017b6448f222776d0143e5f98d1e65
User & Date: drh 2012-03-01 22:06:30.213
Context
2012-03-01
22:33
Do not run the large file tests if a file named "skip-big-file" exists in the test directory. This enables tests to be run much faster on systems that lack sparse file support. (check-in: 5a83912352 user: drh tags: winrt)
22:06
Use SetFilePointerEx() instead of SetFilePointer() on winRT. (check-in: 36efafc618 user: drh tags: winrt)
21:19
Use WaitForSingleObjectEx() as a substitute for Sleep on winRT. (check-in: bf897be0da user: drh tags: winrt)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_win.c.
563
564
565
566
567
568
569



570

571
572
573
574
575
576
577
#define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \
        LPOVERLAPPED))aSyscall[50].pCurrent)

  { "SetEndOfFile",            (SYSCALL)SetEndOfFile,            0 },

#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[51].pCurrent)




  { "SetFilePointer",          (SYSCALL)SetFilePointer,          0 },


#define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \
        DWORD))aSyscall[52].pCurrent)

#if SQLITE_OS_WINRT
  { "Sleep",                   (SYSCALL)0,                       0 },
#else







>
>
>

>







563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
#define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \
        LPOVERLAPPED))aSyscall[50].pCurrent)

  { "SetEndOfFile",            (SYSCALL)SetEndOfFile,            0 },

#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[51].pCurrent)

#if SQLITE_OS_WINRT
  { "SetFilePointer",          (SYSCALL)0,                       0 },
#else
  { "SetFilePointer",          (SYSCALL)SetFilePointer,          0 },
#endif

#define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \
        DWORD))aSyscall[52].pCurrent)

#if SQLITE_OS_WINRT
  { "Sleep",                   (SYSCALL)0,                       0 },
#else
1559
1560
1561
1562
1563
1564
1565

1566
1567
1568
1569
1570
1571
1572
/*
** Some Microsoft compilers lack this definition.
*/
#ifndef INVALID_SET_FILE_POINTER
# define INVALID_SET_FILE_POINTER ((DWORD)-1)
#endif


/*
** Move the current position of the file handle passed as the first 
** argument to offset iOffset within the file. If successful, return 0. 
** Otherwise, set pFile->lastErrno and return non-zero.
*/
static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){
  LONG upperBits;                 /* Most sig. 32 bits of new offset */







>







1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
/*
** Some Microsoft compilers lack this definition.
*/
#ifndef INVALID_SET_FILE_POINTER
# define INVALID_SET_FILE_POINTER ((DWORD)-1)
#endif

#if SQLITE_OS_WINRT==0
/*
** Move the current position of the file handle passed as the first 
** argument to offset iOffset within the file. If successful, return 0. 
** Otherwise, set pFile->lastErrno and return non-zero.
*/
static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){
  LONG upperBits;                 /* Most sig. 32 bits of new offset */
1592
1593
1594
1595
1596
1597
1598











1599
1600
1601
1602
1603
1604
1605
    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
             "seekWinFile", pFile->zPath);
    return 1;
  }

  return 0;
}












/*
** Close a file.
**
** It is reported that an attempt to close a handle might sometimes
** fail.  This is a very unreasonable result, but Windows is notorious
** for being unreasonable so I do not doubt that it might happen.  If







>
>
>
>
>
>
>
>
>
>
>







1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
             "seekWinFile", pFile->zPath);
    return 1;
  }

  return 0;
}
#else /* if SQLITE_OS_WINRT==1 */
/* 
** Same function as above, except that this implementation works for
** windowsRT.
*/
static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){
  LARGE_INTEGER x;
  x.QuadPart = iOffset;
  return SetFilePointerEx(pFile->h, x, 0, FILE_BEGIN) ? 0 : 1;
}
#endif

/*
** Close a file.
**
** It is reported that an attempt to close a handle might sometimes
** fail.  This is a very unreasonable result, but Windows is notorious
** for being unreasonable so I do not doubt that it might happen.  If