mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
31 lines
645 B
Go
31 lines
645 B
Go
package vfs
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/ncruces/go-sqlite3/internal/util"
|
|
"github.com/ncruces/go-sqlite3/sqlite3vfs"
|
|
"github.com/tetratelabs/wazero/api"
|
|
)
|
|
|
|
func vfsAPIGet(mod api.Module, pVfs uint32) sqlite3vfs.VFS {
|
|
if pVfs != 0 {
|
|
name := util.ReadString(mod, util.ReadUint32(mod, pVfs+16), _MAX_STRING)
|
|
if vfs := sqlite3vfs.Find(name); vfs != nil {
|
|
return vfs
|
|
}
|
|
}
|
|
return vfsOS{}
|
|
}
|
|
|
|
func vfsAPIErrorCode(err error, def _ErrorCode) _ErrorCode {
|
|
if err == nil {
|
|
return _OK
|
|
}
|
|
switch v := reflect.ValueOf(err); v.Kind() {
|
|
case reflect.Uint8, reflect.Uint16, reflect.Uint32:
|
|
return _ErrorCode(v.Uint())
|
|
}
|
|
return def
|
|
}
|