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

📄 vfs.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 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 Object</h2><blockquote><pre>typedef struct sqlite3_vfs sqlite3_vfs;struct sqlite3_vfs {  int iVersion;            /* Structure version number */  int szOsFile;            /* Size of subclassed sqlite3_file */  int mxPathname;          /* Maximum file pathname length */  sqlite3_vfs *pNext;      /* Next registered VFS */  const char *zName;       /* Name of this virtual file system */  void *pAppData;          /* Pointer to application-specific data */  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,               int flags, int *pOutFlags);  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);  void (*xDlClose)(sqlite3_vfs*, void*);  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);  int (*xSleep)(sqlite3_vfs*, int microseconds);  int (*xCurrentTime)(sqlite3_vfs*, double*);  int (*xGetLastError)(sqlite3_vfs*, int, char *);  /* New fields may be appended in figure versions.  The iVersion  ** value will increment whenever this happens. */};</pre></blockquote><p>An instance of the sqlite3_vfs object defines the interface betweenthe SQLite core and the underlying operating system.  The "vfs"in the name of the object stands for "virtual file system".</p><p>The value of the iVersion field is initially 1 but may be larger infuture versions of SQLite.  Additional fields may be appended to thisobject when the iVersion value is increased.  Note that the structureof the sqlite3_vfs object changes in the transaction betweenSQLite version 3.5.9 and 3.6.0 and yet the iVersion field was notmodified.</p><p>The szOsFile field is the size of the subclassed <a href="../c3ref/file.html">sqlite3_file</a>structure used by this VFS.  mxPathname is the maximum length ofa pathname in this VFS.</p><p>Registered sqlite3_vfs objects are kept on a linked list formed bythe pNext pointer.  The <a href="../c3ref/vfs_find.html">sqlite3_vfs_register()</a>and <a href="../c3ref/vfs_find.html">sqlite3_vfs_unregister()</a> interfaces manage this listin a thread-safe way.  The <a href="../c3ref/vfs_find.html">sqlite3_vfs_find()</a> interfacesearches the list.  Neither the application code nor the VFSimplementation should use the pNext pointer.</p><p>The pNext field is the only field in the sqlite3_vfsstructure that SQLite will ever modify.  SQLite will only accessor modify this field while holding a particular static mutex.The application should never modify anything within the sqlite3_vfsobject once the object has been registered.</p><p>The zName field holds the name of the VFS module.  The name mustbe unique across all VFS modules.</p><p>SQLite will guarantee that the zFilename parameter to xOpenis either a NULL pointer or string obtainedfrom xFullPathname().  SQLite further guarantees thatthe string will be valid and unchanged until xClose() iscalled. Because of the previous sentense,the <a href="../c3ref/file.html">sqlite3_file</a> can safely store a pointer to thefilename if it needs to remember the filename for some reason.If the zFilename parameter is xOpen is a NULL pointer then xOpenmust invite its own temporary name for the file.  Whenever thexFilename parameter is NULL it will also be the case that theflags parameter will include <a href="../c3ref/c_open_create.html">SQLITE_OPEN_DELETEONCLOSE</a>.</p><p>The flags argument to xOpen() includes all bits set inthe flags argument to <a href="../c3ref/open.html">sqlite3_open_v2()</a>.  Or if <a href="../c3ref/open.html">sqlite3_open()</a>or <a href="../c3ref/open.html">sqlite3_open16()</a> is used, then flags includes at least<a href="../c3ref/c_open_create.html">SQLITE_OPEN_READWRITE</a> | <a href="../c3ref/c_open_create.html">SQLITE_OPEN_CREATE</a>.If xOpen() opens a file read-only then it sets *pOutFlags toinclude <a href="../c3ref/c_open_create.html">SQLITE_OPEN_READONLY</a>.  Other bits in *pOutFlags may be set.</p><p>SQLite will also add one of the following flags to the xOpen()call, depending on the object being opened:</p><p><ul><li>  <a href="../c3ref/c_open_create.html">SQLITE_OPEN_MAIN_DB</a><li>  <a href="../c3ref/c_open_create.html">SQLITE_OPEN_MAIN_JOURNAL</a><li>  <a href="../c3ref/c_open_create.html">SQLITE_OPEN_TEMP_DB</a><li>  <a href="../c3ref/c_open_create.html">SQLITE_OPEN_TEMP_JOURNAL</a><li>  <a href="../c3ref/c_open_create.html">SQLITE_OPEN_TRANSIENT_DB</a><li>  <a href="../c3ref/c_open_create.html">SQLITE_OPEN_SUBJOURNAL</a><li>  <a href="../c3ref/c_open_create.html">SQLITE_OPEN_MASTER_JOURNAL</a></ul></p><p>The file I/O implementation can use the object type flags tochange the way it deals with files.  For example, an applicationthat does not care about crash recovery or rollback might makethe open of a journal file a no-op.  Writes to this journal wouldalso be no-ops, and any attempt to read the journal would returnSQLITE_IOERR.  Or the implementation might recognize that a databasefile will be doing page-aligned sector reads and writes in a randomorder and set up its I/O subsystem accordingly.</p><p>SQLite might also add one of the following flags to the xOpen method:</p><p><ul><li> <a href="../c3ref/c_open_create.html">SQLITE_OPEN_DELETEONCLOSE</a><li> <a href="../c3ref/c_open_create.html">SQLITE_OPEN_EXCLUSIVE</a></ul></p><p>The <a href="../c3ref/c_open_create.html">SQLITE_OPEN_DELETEONCLOSE</a> flag means the file should bedeleted when it is closed.  The <a href="../c3ref/c_open_create.html">SQLITE_OPEN_DELETEONCLOSE</a>will be set for TEMP  databases, journals and for subjournals.</p><p>The <a href="../c3ref/c_open_create.html">SQLITE_OPEN_EXCLUSIVE</a> flag means the file should be openedfor exclusive access.  This flag is set for all files exceptfor the main database file.</p><p>At least szOsFile bytes of memory are allocated by SQLiteto hold the  <a href="../c3ref/file.html">sqlite3_file</a> structure passed as the thirdargument to xOpen.  The xOpen method does not have toallocate the structure; it should just fill it in.</p><p>The flags argument to xAccess() may be <a href="../c3ref/c_access_exists.html">SQLITE_ACCESS_EXISTS</a>to test for the existence of a file, or <a href="../c3ref/c_access_exists.html">SQLITE_ACCESS_READWRITE</a> totest whether a file is readable and writable, or <a href="../c3ref/c_access_exists.html">SQLITE_ACCESS_READ</a>to test whether a file is at least readable.   The file can be adirectory.</p><p>SQLite will always allocate at least mxPathname+1 bytes for theoutput buffer xFullPathname.  The exact size of the output bufferis also passed as a parameter to both  methods. If the output bufferis not large enough, <a href="../c3ref/c_abort.html">SQLITE_CANTOPEN</a> should be returned. Since this ishandled as a fatal error by SQLite, vfs implementations should endeavorto prevent this by setting mxPathname to a sufficiently large value.</p><p>The xRandomness(), xSleep(), and xCurrentTime() interfacesare not strictly a part of the filesystem, but they areincluded in the VFS structure for completeness.The xRandomness() function attempts to return nBytes bytesof good-quality randomness into zOut.  The return value isthe actual number of bytes of randomness obtained.The xSleep() method causes the calling thread to sleep for atleast the number of microseconds given.  The xCurrentTime()method returns a Julian Day Number for the current date and time.</p><p></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 + -