diff options
author | shane <shane@noemail.net> | 2008-10-12 02:27:38 +0000 |
---|---|---|
committer | shane <shane@noemail.net> | 2008-10-12 02:27:38 +0000 |
commit | a3465f2d78611a2ccf2eccccf03d56c6ead6f04b (patch) | |
tree | b1cf4088ab9bf5a083133c27b9c025b8fa7d9324 /src | |
parent | e5447f5c1ca9eeba8753add1b61302da7c05ff41 (diff) | |
download | sqlite-a3465f2d78611a2ccf2eccccf03d56c6ead6f04b.tar.gz sqlite-a3465f2d78611a2ccf2eccccf03d56c6ead6f04b.zip |
Check for failures in winTruncate. Ticket #3415. (CVS 5811)
FossilOrigin-Name: 500c50561fba88948aad21d1aef1e1e96ab8c3aa
Diffstat (limited to 'src')
-rw-r--r-- | src/os_win.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/os_win.c b/src/os_win.c index d9f195099..508e9179f 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -12,7 +12,7 @@ ** ** This file contains code that is specific to windows. ** -** $Id: os_win.c,v 1.134 2008/09/30 04:20:08 shane Exp $ +** $Id: os_win.c,v 1.135 2008/10/12 02:27:39 shane Exp $ */ #include "sqliteInt.h" #if SQLITE_OS_WIN /* This file is used for windows only */ @@ -713,14 +713,20 @@ static int winWrite( ** Truncate an open file to a specified size */ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){ + DWORD rc; LONG upperBits = (nByte>>32) & 0x7fffffff; LONG lowerBits = nByte & 0xffffffff; winFile *pFile = (winFile*)id; OSTRACE3("TRUNCATE %d %lld\n", pFile->h, nByte); SimulateIOError(return SQLITE_IOERR_TRUNCATE); - SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); - SetEndOfFile(pFile->h); - return SQLITE_OK; + rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); + if( INVALID_SET_FILE_POINTER != rc ){ + /* SetEndOfFile will fail if nByte is negative */ + if( SetEndOfFile(pFile->h) ){ + return SQLITE_OK; + } + } + return SQLITE_IOERR_TRUNCATE; } #ifdef SQLITE_TEST |