mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Build fiddle with WASMFS OPFS support and attempt to use it if available. It does not work because of an inexplicable exception in Emscripten-generated code and perpetually-locked db, but it's not yet clear why.
FossilOrigin-Name: a16f0a46ec88c560f73d5664e4bf53fb5dd1a22e99a92c11b5c8d784816c3282
This commit is contained in:
@ -411,3 +411,49 @@ const char * sqlite3_wasm_enum_json(void){
|
||||
#undef outf
|
||||
#undef lenCheck
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is NOT part of the sqlite3 public API. It is strictly
|
||||
** for use by the sqlite project's own JS/WASM bindings.
|
||||
**
|
||||
** This function invokes the xDelete method of the default VFS,
|
||||
** passing on the given filename. If zName is NULL, no default VFS is
|
||||
** found, or it has no xDelete method, SQLITE_MISUSE is returned, else
|
||||
** the result of the xDelete() call is returned.
|
||||
*/
|
||||
int sqlite3_wasm_vfs_unlink(const char * zName){
|
||||
int rc = SQLITE_MISUSE /* ??? */;
|
||||
sqlite3_vfs * const pVfs = sqlite3_vfs_find(0);
|
||||
if( zName && pVfs && pVfs->xDelete ){
|
||||
rc = pVfs->xDelete(pVfs, zName, 1);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/wasmfs.h>
|
||||
#include <emscripten/console.h>
|
||||
/*
|
||||
** This function is NOT part of the sqlite3 public API. It is strictly
|
||||
** for use by the sqlite project's own JS/WASM bindings.
|
||||
**
|
||||
** This function should only be called if the JS side detects the
|
||||
** existence of the Origin-Private FileSystem (OPFS) APIs in the
|
||||
** client. The first time it is called, this function instantiates a
|
||||
** WASMFS backend impl for OPFS. On success, subsequent calls are
|
||||
** no-ops.
|
||||
**
|
||||
** Returns 0 on success, SQLITE_NOMEM if intantiation of the backend
|
||||
** object fails.
|
||||
*/
|
||||
int sqlite3_wasm_init_opfs(void){
|
||||
static backend_t pOpfs = 0;
|
||||
if( !pOpfs ){
|
||||
pOpfs = wasmfs_create_opfs_backend();
|
||||
if( pOpfs ){
|
||||
emscripten_console_log("Created OPFS WASMFS backend.");
|
||||
}
|
||||
}
|
||||
return pOpfs ? 0 : SQLITE_NOMEM;
|
||||
}
|
||||
#endif /* __EMSCRIPTEN__ */
|
||||
|
Reference in New Issue
Block a user