⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 io_methods.html

📁 sqlite3源码,适合作为嵌入式(embedded)
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>OS Interface File Virtual Methods Object</title><style type="text/css">body {    margin: auto;    font-family: "Verdana" "sans-serif";    padding: 8px 1%;}a { color: #45735f }a:visited { color: #734559 }.logo { position:absolute; margin:3px; }.tagline {  float:right;  text-align:right;  font-style:italic;  width:240px;  margin:12px;  margin-top:58px;}.toolbar {  font-variant: small-caps;  text-align: center;  line-height: 1.6em;  margin: 0;  padding:1px 8px;}.toolbar a { color: white; text-decoration: none; padding: 6px 12px; }.toolbar a:visited { color: white; }.toolbar a:hover { color: #80a796; background: white; }.content    { margin: 5%; }.content dt { font-weight:bold; }.content dd { margin-bottom: 25px; margin-left:20%; }.content ul { padding:0px; padding-left: 15px; margin:0px; }/* rounded corners */.se  { background: url(../images/se.png) 100% 100% no-repeat #80a796}.sw  { background: url(../images/sw.png) 0% 100% no-repeat }.ne  { background: url(../images/ne.png) 100% 0% no-repeat }.nw  { background: url(../images/nw.png) 0% 0% no-repeat }</style><meta http-equiv="content-type" content="text/html; charset=UTF-8">  </head><body><div><!-- container div to satisfy validator --><a href="../index.html"><img class="logo" src="../images/SQLite.gif" alt="SQLite Logo" border="0"></a><div><!-- IE hack to prevent disappearing logo--></div><div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div><table width=100% style="clear:both"><tr><td>  <div class="se"><div class="sw"><div class="ne"><div class="nw">  <div class="toolbar">    <a href="../about.html">About</a>    <a href="../sitemap.html">Sitemap</a>    <a href="../docs.html">Documentation</a>    <a href="../download.html">Download</a>    <a href="../copyright.html">License</a>    <a href="../news.html">News</a>    <a href="http://www.sqlite.org/cvstrac/index">Developers</a>    <a href="../support.html">Support</a>  </div></div></div></div></div></td></tr></table>  <a href="intro.html"><h2>SQLite C Interface</h2></a><h2>OS Interface File Virtual Methods Object</h2><blockquote><pre>typedef struct sqlite3_io_methods sqlite3_io_methods;struct sqlite3_io_methods {  int iVersion;  int (*xClose)(sqlite3_file*);  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);  int (*xSync)(sqlite3_file*, int flags);  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);  int (*xLock)(sqlite3_file*, int);  int (*xUnlock)(sqlite3_file*, int);  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);  int (*xFileControl)(sqlite3_file*, int op, void *pArg);  int (*xSectorSize)(sqlite3_file*);  int (*xDeviceCharacteristics)(sqlite3_file*);  /* Additional methods may be added in future releases */};</pre></blockquote><p>Every file opened by the <a href="../c3ref/vfs.html">sqlite3_vfs</a> xOpen method populates an<a href="../c3ref/file.html">sqlite3_file</a> object (or, more commonly, a subclass of the<a href="../c3ref/file.html">sqlite3_file</a> object) with a pointer to an instance of this object.This object defines the methods used to perform various operationsagainst the open file represented by the <a href="../c3ref/file.html">sqlite3_file</a> object.</p><p>The flags argument to xSync may be one of <a href="../c3ref/c_sync_dataonly.html">SQLITE_SYNC_NORMAL</a> or<a href="../c3ref/c_sync_dataonly.html">SQLITE_SYNC_FULL</a>.  The first choice is the normal fsync().The second choice is a Mac OS X style fullsync.  The <a href="../c3ref/c_sync_dataonly.html">SQLITE_SYNC_DATAONLY</a>flag may be ORed in to indicate that only the data of the fileand not its inode needs to be synced.</p><p>The integer values to xLock() and xUnlock() are one of<ul><li> <a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_NONE</a>,<li> <a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_SHARED</a>,<li> <a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_RESERVED</a>,<li> <a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_PENDING</a>, or<li> <a href="../c3ref/c_lock_exclusive.html">SQLITE_LOCK_EXCLUSIVE</a>.</ul>xLock() increases the lock. xUnlock() decreases the lock.The xCheckReservedLock() method checks whether any database connection,either in this process or in some other process, is holding a RESERVED,PENDING, or EXCLUSIVE lock on the file.  It returns trueif such a lock exists and false otherwise.</p><p>The xFileControl() method is a generic interface that allows customVFS implementations to directly control an open file using the<a href="../c3ref/file_control.html">sqlite3_file_control()</a> interface.  The second "op" argument is aninteger opcode.  The third argument is a generic pointer intended topoint to a structure that may contain arguments or space in which towrite return values.  Potential uses for xFileControl() might befunctions to enable blocking locks with timeouts, to change thelocking strategy (for example to use dot-file locks), to inquireabout the status of a lock, or to break stale locks.  The SQLitecore reserves all opcodes less than 100 for its own use.A <a href="../c3ref/c_fcntl_lockstate.html">list of opcodes</a> less than 100 is available.Applications that define a custom xFileControl method should use opcodesgreater than 100 to avoid conflicts.</p><p>The xSectorSize() method returns the sector size of thedevice that underlies the file.  The sector size is theminimum write that can be performed without disturbingother bytes in the file.  The xDeviceCharacteristics()method returns a bit vector describing behaviors of theunderlying device:</p><p><ul><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC512</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC1K</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC2K</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC4K</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC8K</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC16K</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC32K</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_ATOMIC64K</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_SAFE_APPEND</a><li> <a href="../c3ref/c_iocap_atomic.html">SQLITE_IOCAP_SEQUENTIAL</a></ul></p><p>The SQLITE_IOCAP_ATOMIC property means that all writes ofany size are atomic.  The SQLITE_IOCAP_ATOMICnnn valuesmean that writes of blocks that are nnn bytes in size andare aligned to an address which is an integer multiple ofnnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value meansthat when data is appended to a file, the data is appendedfirst then the size of the file is extended, never the otherway around.  The SQLITE_IOCAP_SEQUENTIAL property means thatinformation is written to disk in the same order as callsto xWrite().</p><p>If xRead() returns SQLITE_IOERR_SHORT_READ it must also fillin the unread portions of the buffer with zeros.  A VFS thatfails to zero-fill short reads might seem to work.  However,failure to zero-fill short reads will eventually lead todatabase corruption.</p><p>See also lists of  <a href="objlist.html">Objects</a>,  <a href="constlist.html">Constants</a>, and  <a href="funclist.html">Functions</a>.</p><hr><small><i>This page last modified 2008/12/09 18:44:04 UTC</i></small></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -