extensions/sqlite/sqlite-source/os.c
changeset 1203 633c25ce6405
child 1645 27307df4d711
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/sqlite/sqlite-source/os.c	Sun Jul 29 01:15:31 2007 +0000
     1.3 @@ -0,0 +1,96 @@
     1.4 +/*
     1.5 +** 2005 November 29
     1.6 +**
     1.7 +** The author disclaims copyright to this source code.  In place of
     1.8 +** a legal notice, here is a blessing:
     1.9 +**
    1.10 +**    May you do good and not evil.
    1.11 +**    May you find forgiveness for yourself and forgive others.
    1.12 +**    May you share freely, never taking more than you give.
    1.13 +**
    1.14 +******************************************************************************
    1.15 +**
    1.16 +** This file contains OS interface code that is common to all
    1.17 +** architectures.
    1.18 +*/
    1.19 +#define _SQLITE_OS_C_ 1
    1.20 +#include "sqliteInt.h"
    1.21 +#include "os.h"
    1.22 +#undef _SQLITE_OS_C_
    1.23 +
    1.24 +/*
    1.25 +** The following routines are convenience wrappers around methods
    1.26 +** of the OsFile object.  This is mostly just syntactic sugar.  All
    1.27 +** of this would be completely automatic if SQLite were coded using
    1.28 +** C++ instead of plain old C.
    1.29 +*/
    1.30 +int sqlite3OsClose(OsFile **pId){
    1.31 +  OsFile *id;
    1.32 +  if( pId!=0 && (id = *pId)!=0 ){
    1.33 +    return id->pMethod->xClose(pId);
    1.34 +  }else{
    1.35 +    return SQLITE_OK;
    1.36 +  }
    1.37 +}
    1.38 +int sqlite3OsOpenDirectory(OsFile *id, const char *zName){
    1.39 +  return id->pMethod->xOpenDirectory(id, zName);
    1.40 +}
    1.41 +int sqlite3OsRead(OsFile *id, void *pBuf, int amt){
    1.42 +  return id->pMethod->xRead(id, pBuf, amt);
    1.43 +}
    1.44 +int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){
    1.45 +  return id->pMethod->xWrite(id, pBuf, amt);
    1.46 +}
    1.47 +int sqlite3OsSeek(OsFile *id, i64 offset){
    1.48 +  return id->pMethod->xSeek(id, offset);
    1.49 +}
    1.50 +int sqlite3OsTruncate(OsFile *id, i64 size){
    1.51 +  return id->pMethod->xTruncate(id, size);
    1.52 +}
    1.53 +int sqlite3OsSync(OsFile *id, int fullsync){
    1.54 +  return id->pMethod->xSync(id, fullsync);
    1.55 +}
    1.56 +void sqlite3OsSetFullSync(OsFile *id, int value){
    1.57 +  id->pMethod->xSetFullSync(id, value);
    1.58 +}
    1.59 +int sqlite3OsFileSize(OsFile *id, i64 *pSize){
    1.60 +  return id->pMethod->xFileSize(id, pSize);
    1.61 +}
    1.62 +int sqlite3OsLock(OsFile *id, int lockType){
    1.63 +  return id->pMethod->xLock(id, lockType);
    1.64 +}
    1.65 +int sqlite3OsUnlock(OsFile *id, int lockType){
    1.66 +  return id->pMethod->xUnlock(id, lockType);
    1.67 +}
    1.68 +int sqlite3OsCheckReservedLock(OsFile *id){
    1.69 +  return id->pMethod->xCheckReservedLock(id);
    1.70 +}
    1.71 +int sqlite3OsSectorSize(OsFile *id){
    1.72 +  int (*xSectorSize)(OsFile*) = id->pMethod->xSectorSize;
    1.73 +  return xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE;
    1.74 +}
    1.75 +
    1.76 +#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
    1.77 +  /* These methods are currently only used for testing and debugging. */
    1.78 +  int sqlite3OsFileHandle(OsFile *id){
    1.79 +    return id->pMethod->xFileHandle(id);
    1.80 +  }
    1.81 +  int sqlite3OsLockState(OsFile *id){
    1.82 +    return id->pMethod->xLockState(id);
    1.83 +  }
    1.84 +#endif
    1.85 +
    1.86 +#ifdef SQLITE_ENABLE_REDEF_IO
    1.87 +/*
    1.88 +** A function to return a pointer to the virtual function table.
    1.89 +** This routine really does not accomplish very much since the
    1.90 +** virtual function table is a global variable and anybody who
    1.91 +** can call this function can just as easily access the variable
    1.92 +** for themselves.  Nevertheless, we include this routine for
    1.93 +** backwards compatibility with an earlier redefinable I/O
    1.94 +** interface design.
    1.95 +*/
    1.96 +struct sqlite3OsVtbl *sqlite3_os_switch(void){
    1.97 +  return &sqlite3Os;
    1.98 +}
    1.99 +#endif