mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
40 lines
798 B
Go
40 lines
798 B
Go
package sqlite3vfs
|
|
|
|
import "sync"
|
|
|
|
var (
|
|
vfsRegistry map[string]VFS
|
|
vfsRegistryMtx sync.Mutex
|
|
)
|
|
|
|
// Find returns a VFS given its name.
|
|
// If there is no match, nil is returned.
|
|
//
|
|
// https://www.sqlite.org/c3ref/vfs_find.html
|
|
func Find(name string) VFS {
|
|
vfsRegistryMtx.Lock()
|
|
defer vfsRegistryMtx.Unlock()
|
|
return vfsRegistry[name]
|
|
}
|
|
|
|
// Register registers a VFS.
|
|
//
|
|
// https://www.sqlite.org/c3ref/vfs_find.html
|
|
func Register(name string, vfs VFS) {
|
|
vfsRegistryMtx.Lock()
|
|
defer vfsRegistryMtx.Unlock()
|
|
if vfsRegistry == nil {
|
|
vfsRegistry = map[string]VFS{}
|
|
}
|
|
vfsRegistry[name] = vfs
|
|
}
|
|
|
|
// Unregister unregisters a VFS.
|
|
//
|
|
// https://www.sqlite.org/c3ref/vfs_find.html
|
|
func Unregister(name string) {
|
|
vfsRegistryMtx.Lock()
|
|
defer vfsRegistryMtx.Unlock()
|
|
delete(vfsRegistry, name)
|
|
}
|