From 842c5ee84951da8524221e0546d41e4f3a1a18f0 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 20 Oct 2022 05:14:37 +0000 Subject: Rework sqlite3_wasm_vfs_unlink(), add sqlite3_wasm_db_vfs(), update some docs. FossilOrigin-Name: cdd46858f0e63bc7bfce8e339b3db9efdec43b6443ee76563a847f53d0176831 --- ext/wasm/api/sqlite3-wasm.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'ext/wasm/api/sqlite3-wasm.c') diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index cda4e7ae2..1decf0593 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -809,28 +809,38 @@ const char * sqlite3_wasm_enum_json(void){ ** This function is NOT part of the sqlite3 public API. It is strictly ** for use by the sqlite project's own JS/WASM bindings. ** -** Do not use this function, even for internal use: it was -** ill-conceived and will be removed once the JS code which still -** calls it has been weeded out. -** -** 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. +** This function invokes the xDelete method of the given VFS (or the +** default VFS if pVfs is NULL), 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. */ SQLITE_WASM_KEEP -int sqlite3_wasm_vfs_unlink(const char * zName){ +int sqlite3_wasm_vfs_unlink(sqlite3_vfs *pVfs, const char * zName){ int rc = SQLITE_MISUSE /* ??? */; - sqlite3_vfs * const pVfs = sqlite3_vfs_find(0); -#if defined(__EMSCRIPTEN__) - emscripten_console_warn("sqlite3_wasm_vfs_unlink() will be removed."); -#endif + if( 0==pVfs && 0!=zName ) pVfs = sqlite3_vfs_find(0); if( zName && pVfs && pVfs->xDelete ){ rc = pVfs->xDelete(pVfs, zName, 1); } return rc; } +/* +** This function is NOT part of the sqlite3 public API. It is strictly +** for use by the sqlite project's own JS/WASM bindings. +** +** Returns a pointer to the given DB's VFS for the given DB name, +** defaulting to "main" if zDbName is 0. Returns 0 if no db with the +** given name is open. +*/ +SQLITE_WASM_KEEP +sqlite3_vfs * sqlite3_wasm_db_vfs(sqlite3 *pDb, const char *zDbName){ + sqlite3_vfs * pVfs = 0; + sqlite3_file_control(pDb, zDbName ? zDbName : "main", + SQLITE_FCNTL_VFS_POINTER, &pVfs); + return pVfs; +} + /* ** This function is NOT part of the sqlite3 public API. It is strictly ** for use by the sqlite project's own JS/WASM bindings. -- cgit v1.2.3