@@ -162,7 +162,8 @@ int VfsRdOnlyDeviceCharacteristics(sqlite3_file * /*pFile*/)
162
162
}
163
163
164
164
// //////////////////////////////////////////////////////////////////////////
165
- // / Set the function pointers of the custom VFS implementation
165
+ // / Set the function pointers of the custom VFS I/O operations in a
166
+ // / forward-compatible way
166
167
static sqlite3_io_methods GetSqlite3IoMethods ()
167
168
{
168
169
// The C style initialization is compatible with version 1 and later versions of the struct.
@@ -293,33 +294,33 @@ int VfsRdOnlyCurrentTime(sqlite3_vfs *vfs, double *prNow)
293
294
return rc;
294
295
}
295
296
297
+ // //////////////////////////////////////////////////////////////////////////
298
+ // / Set the function pointers of the VFS implementation in a
299
+ // / forward-compatible way
300
+ static sqlite3_vfs GetSqlite3Vfs ()
301
+ {
302
+ // The C style initialization is compatible with version 1 and later versions of the struct.
303
+ // Version 1 was introduced with sqlite 3.5, version 2 with sqlite 3.7, version 3 with sqlite 3.7.6
304
+ sqlite3_vfs vfs;
305
+ memset (&vfs, 0 , sizeof (vfs));
306
+ vfs.iVersion = 1 ;
307
+ vfs.szOsFile = sizeof (VfsRootFile);
308
+ vfs.mxPathname = 2000 ;
309
+ vfs.zName = gSQliteVfsName ;
310
+ vfs.xOpen = VfsRdOnlyOpen;
311
+ vfs.xDelete = VfsRdOnlyDelete;
312
+ vfs.xAccess = VfsRdOnlyAccess;
313
+ vfs.xFullPathname = VfsRdOnlyFullPathname;
314
+ vfs.xRandomness = VfsRdOnlyRandomness;
315
+ vfs.xSleep = VfsRdOnlySleep;
316
+ vfs.xCurrentTime = VfsRdOnlyCurrentTime;
317
+ vfs.xGetLastError = VfsRdOnlyGetLastError;
318
+ return vfs;
319
+ }
320
+
296
321
// //////////////////////////////////////////////////////////////////////////
297
322
// / A global struct of function pointers and details on the VfsRootFile class that together constitue a VFS module
298
- static struct sqlite3_vfs kSqlite3Vfs = {
299
- 1 , // version of the struct
300
- sizeof (VfsRootFile),
301
- 2000 , // maximum URL length
302
- nullptr , // pNext, maintained by sqlite
303
- gSQliteVfsName ,
304
- nullptr , // pAppData
305
- VfsRdOnlyOpen,
306
- VfsRdOnlyDelete,
307
- VfsRdOnlyAccess,
308
- VfsRdOnlyFullPathname,
309
- nullptr , // xDlOpen
310
- nullptr , // xDlError
311
- nullptr , // xDlSym
312
- nullptr , // xDlClose
313
- VfsRdOnlyRandomness,
314
- VfsRdOnlySleep,
315
- VfsRdOnlyCurrentTime,
316
- VfsRdOnlyGetLastError,
317
- VfsRdOnlyCurrentTimeInt64,
318
- // Version 3 and later callbacks
319
- nullptr , // xSetSystemCall
320
- nullptr , // xGetSystemCall
321
- nullptr , // xNextSystemCall
322
- };
323
+ static struct sqlite3_vfs kSqlite3Vfs = GetSqlite3Vfs();
323
324
324
325
static bool RegisterSqliteVfs ()
325
326
{
0 commit comments