From: drh Date: Thu, 1 Mar 2012 22:44:56 +0000 (+0000) Subject: Use GetInformationByHandleEx() instead of GetFileSize() on winRT. X-Git-Tag: version-3.7.13~11^2~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=24560d16e9bd1830eb60531e8f9f14e0f3444212;p=thirdparty%2Fsqlite.git Use GetInformationByHandleEx() instead of GetFileSize() on winRT. FossilOrigin-Name: 119f251de77aa88cf8ff9fcc72bfbecbe6b741e3 --- diff --git a/manifest b/manifest index 891f0fae2f..584968e7cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\srun\sthe\slarge\sfile\stests\sif\sa\sfile\snamed\s"skip-big-file"\sexists\nin\sthe\stest\sdirectory.\s\sThis\senables\stests\sto\sbe\srun\smuch\sfaster\son\nsystems\sthat\slack\ssparse\sfile\ssupport. -D 2012-03-01T22:33:41.379 +C Use\sGetInformationByHandleEx()\sinstead\sof\sGetFileSize()\son\swinRT. +D 2012-03-01T22:44:56.767 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c f5d551ef6c6988fb5ed96c4f60eb67bd5cce78e4 +F src/os_win.c c7fc501c60d979dc038de0d893c37aff2af754c3 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 36efafc618017b6448f222776d0143e5f98d1e65 -R 86df3dcfb999c945a7ab3c5f3898aaba +P 5a83912352ad6626970efd72e70c433e3a219b6b +R 97ff50ee0fb884b5de3a1afe57f30d4e U drh -Z a38013646615f1ec6a50fcd20d1bf262 +Z de1a0224f4c15abe9eff3a7b951c1850 diff --git a/manifest.uuid b/manifest.uuid index 6932e7e039..693bf5bf2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a83912352ad6626970efd72e70c433e3a219b6b \ No newline at end of file +119f251de77aa88cf8ff9fcc72bfbecbe6b741e3 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 526dd5a844..91ecaaebc7 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -388,7 +388,11 @@ static struct win_syscall { #define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \ LPVOID))aSyscall[22].pCurrent) +#if SQLITE_OS_WINRT + { "GetFileSize", (SYSCALL)0, 0 }, +#else { "GetFileSize", (SYSCALL)GetFileSize, 0 }, +#endif #define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent) @@ -1861,23 +1865,39 @@ static int winSync(sqlite3_file *id, int flags){ ** Determine the current size of a file in bytes */ static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){ - DWORD upperBits; - DWORD lowerBits; winFile *pFile = (winFile*)id; - DWORD lastErrno; + int rc = SQLITE_OK; assert( id!=0 ); SimulateIOError(return SQLITE_IOERR_FSTAT); - lowerBits = osGetFileSize(pFile->h, &upperBits); - if( (lowerBits == INVALID_FILE_SIZE) - && ((lastErrno = osGetLastError())!=NO_ERROR) ) +#if SQLITE_OS_WINRT { - pFile->lastErrno = lastErrno; - return winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, + FILE_STANDARD_INFO info; + if( GetFileInformationByHandleEx(pFile->h, FileStandardInfo, + &info, sizeof(info)) ){ + *pSize = info.EndOfFile.QuadPart; + }else{ + rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, + "winFileSize", pFile->zPath); + } + } +#else + { + DWORD upperBits; + DWORD lowerBits; + DWORD lastErrno; + + lowerBits = osGetFileSize(pFile->h, &upperBits); + *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits; + if( (lowerBits == INVALID_FILE_SIZE) + && ((lastErrno = osGetLastError())!=NO_ERROR) ){ + pFile->lastErrno = lastErrno; + rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, "winFileSize", pFile->zPath); + } } - *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits; - return SQLITE_OK; +#endif + return rc; } /*