diff options
author | drh <drh@noemail.net> | 2005-11-30 03:20:31 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2005-11-30 03:20:31 +0000 |
commit | 054889ec6d2df4754468d2acfe6c92973f54ea2c (patch) | |
tree | 0dd1f8d5015e064fd666cb6253ad10c202ba4e34 /src/os.c | |
parent | 392b3ddf2ebe613d701ff3f912ac04b294ce0070 (diff) | |
download | sqlite-054889ec6d2df4754468d2acfe6c92973f54ea2c.tar.gz sqlite-054889ec6d2df4754468d2acfe6c92973f54ea2c.zip |
Restructure the OS interface yet again. This time make the OsFile object
a virtual base class which is subclassed for unix, windows, and the crash
test simulator. Add the new file "os.c" for common os layer code. Move
all OS-specific routines into the sqlite3Os structure. (CVS 2795)
FossilOrigin-Name: bd8740d1aecba69e1b5d64d43db07e8ad8841f07
Diffstat (limited to 'src/os.c')
-rw-r--r-- | src/os.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/os.c b/src/os.c new file mode 100644 index 000000000..97036746a --- /dev/null +++ b/src/os.c @@ -0,0 +1,71 @@ +/* +** 2005 November 29 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains OS interface code that is common to all +** architectures. +*/ +#include "sqliteInt.h" +#include "os.h" + +/* +** The following routines are convenience wrappers around methods +** of the OsFile object. This is mostly just syntactic sugar. All +** of this would be completely automatic if SQLite were coded using +** C++ instead of plain old C. +*/ +int sqlite3OsClose(OsFile **pId){ + OsFile *id; + if( pId!=0 && (id = *pId)!=0 ){ + return id->pMethod->xClose(pId); + }else{ + return SQLITE_OK; + } +} +int sqlite3OsOpenDirectory(OsFile *id, const char *zName){ + return id->pMethod->xOpenDirectory(id, zName); +} +int sqlite3OsRead(OsFile *id, void *pBuf, int amt){ + return id->pMethod->xRead(id, pBuf, amt); +} +int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){ + return id->pMethod->xWrite(id, pBuf, amt); +} +int sqlite3OsSeek(OsFile *id, i64 offset){ + return id->pMethod->xSeek(id, offset); +} +int sqlite3OsTruncate(OsFile *id, i64 size){ + return id->pMethod->xTruncate(id, size); +} +int sqlite3OsSync(OsFile *id, int fullsync){ + return id->pMethod->xSync(id, fullsync); +} +void sqlite3OsSetFullSync(OsFile *id, int value){ + id->pMethod->xSetFullSync(id, value); +} +int sqlite3OsFileHandle(OsFile *id){ + return id->pMethod->xFileHandle(id); +} +int sqlite3OsFileSize(OsFile *id, i64 *pSize){ + return id->pMethod->xFileSize(id, pSize); +} +int sqlite3OsLock(OsFile *id, int lockType){ + return id->pMethod->xLock(id, lockType); +} +int sqlite3OsUnlock(OsFile *id, int lockType){ + return id->pMethod->xUnlock(id, lockType); +} +int sqlite3OsLockState(OsFile *id){ + return id->pMethod->xLockState(id); +} +int sqlite3OsCheckReservedLock(OsFile *id){ + return id->pMethod->xCheckReservedLock(id); +} |