drh | 054889e | 2005-11-30 03:20:31 +0000 | [diff] [blame^] | 1 | /* |
| 2 | ** 2005 November 29 |
| 3 | ** |
| 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
| 6 | ** |
| 7 | ** May you do good and not evil. |
| 8 | ** May you find forgiveness for yourself and forgive others. |
| 9 | ** May you share freely, never taking more than you give. |
| 10 | ** |
| 11 | ****************************************************************************** |
| 12 | ** |
| 13 | ** This file contains OS interface code that is common to all |
| 14 | ** architectures. |
| 15 | */ |
| 16 | #include "sqliteInt.h" |
| 17 | #include "os.h" |
| 18 | |
| 19 | /* |
| 20 | ** The following routines are convenience wrappers around methods |
| 21 | ** of the OsFile object. This is mostly just syntactic sugar. All |
| 22 | ** of this would be completely automatic if SQLite were coded using |
| 23 | ** C++ instead of plain old C. |
| 24 | */ |
| 25 | int sqlite3OsClose(OsFile **pId){ |
| 26 | OsFile *id; |
| 27 | if( pId!=0 && (id = *pId)!=0 ){ |
| 28 | return id->pMethod->xClose(pId); |
| 29 | }else{ |
| 30 | return SQLITE_OK; |
| 31 | } |
| 32 | } |
| 33 | int sqlite3OsOpenDirectory(OsFile *id, const char *zName){ |
| 34 | return id->pMethod->xOpenDirectory(id, zName); |
| 35 | } |
| 36 | int sqlite3OsRead(OsFile *id, void *pBuf, int amt){ |
| 37 | return id->pMethod->xRead(id, pBuf, amt); |
| 38 | } |
| 39 | int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){ |
| 40 | return id->pMethod->xWrite(id, pBuf, amt); |
| 41 | } |
| 42 | int sqlite3OsSeek(OsFile *id, i64 offset){ |
| 43 | return id->pMethod->xSeek(id, offset); |
| 44 | } |
| 45 | int sqlite3OsTruncate(OsFile *id, i64 size){ |
| 46 | return id->pMethod->xTruncate(id, size); |
| 47 | } |
| 48 | int sqlite3OsSync(OsFile *id, int fullsync){ |
| 49 | return id->pMethod->xSync(id, fullsync); |
| 50 | } |
| 51 | void sqlite3OsSetFullSync(OsFile *id, int value){ |
| 52 | id->pMethod->xSetFullSync(id, value); |
| 53 | } |
| 54 | int sqlite3OsFileHandle(OsFile *id){ |
| 55 | return id->pMethod->xFileHandle(id); |
| 56 | } |
| 57 | int sqlite3OsFileSize(OsFile *id, i64 *pSize){ |
| 58 | return id->pMethod->xFileSize(id, pSize); |
| 59 | } |
| 60 | int sqlite3OsLock(OsFile *id, int lockType){ |
| 61 | return id->pMethod->xLock(id, lockType); |
| 62 | } |
| 63 | int sqlite3OsUnlock(OsFile *id, int lockType){ |
| 64 | return id->pMethod->xUnlock(id, lockType); |
| 65 | } |
| 66 | int sqlite3OsLockState(OsFile *id){ |
| 67 | return id->pMethod->xLockState(id); |
| 68 | } |
| 69 | int sqlite3OsCheckReservedLock(OsFile *id){ |
| 70 | return id->pMethod->xCheckReservedLock(id); |
| 71 | } |