mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Add large file support to Windows. Change large file support for Unix so
that it compiles automatically - without requiring special options on the compiler command line. (CVS 781) FossilOrigin-Name: 2008b56fe11e49d52e28f47d14ccd70504e6c094
This commit is contained in:
18
src/os.c
18
src/os.c
@@ -14,8 +14,8 @@
|
||||
** systems. The purpose of this file is to provide a uniform abstraction
|
||||
** on which the rest of SQLite can operate.
|
||||
*/
|
||||
#include "os.h" /* Must be first to enable large file support */
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
|
||||
#if OS_UNIX
|
||||
# include <time.h>
|
||||
@@ -544,7 +544,10 @@ int sqliteOsSeek(OsFile *id, off_t offset){
|
||||
return SQLITE_OK;
|
||||
#endif
|
||||
#if OS_WIN
|
||||
SetFilePointer(id->h, offset, 0, FILE_BEGIN);
|
||||
{
|
||||
LONG upperBits = offset>>32;
|
||||
SetFilePointer(id->h, offset, &upperBits, FILE_BEGIN);
|
||||
}
|
||||
return SQLITE_OK;
|
||||
#endif
|
||||
}
|
||||
@@ -580,8 +583,11 @@ int sqliteOsTruncate(OsFile *id, off_t nByte){
|
||||
return ftruncate(id->fd, nByte)==0 ? SQLITE_OK : SQLITE_IOERR;
|
||||
#endif
|
||||
#if OS_WIN
|
||||
SetFilePointer(id->h, nByte, 0, FILE_BEGIN);
|
||||
SetEndOfFile(id->h);
|
||||
{
|
||||
LONG upperBits = nByte>>32;
|
||||
SetFilePointer(id->h, nByte, &upperBits, FILE_BEGIN);
|
||||
SetEndOfFile(id->h);
|
||||
}
|
||||
return SQLITE_OK;
|
||||
#endif
|
||||
}
|
||||
@@ -600,8 +606,10 @@ int sqliteOsFileSize(OsFile *id, off_t *pSize){
|
||||
return SQLITE_OK;
|
||||
#endif
|
||||
#if OS_WIN
|
||||
DWORD upperBits, lowerBits;
|
||||
SimulateIOError(SQLITE_IOERR);
|
||||
*pSize = GetFileSize(id->h, 0);
|
||||
lowerBits = GetFileSize(id->h, &upperBits);
|
||||
*pSize = (((off_t)upperBits)<<32) + lowerBits;
|
||||
return SQLITE_OK;
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user