mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
VFS improvements.
This commit is contained in:
@@ -69,20 +69,26 @@ func (*SliceFile) Close() error { return nil }
|
||||
func (*SliceFile) Sync(flags vfs.SyncFlag) error { return nil }
|
||||
|
||||
// Lock implements [vfs.File].
|
||||
func (*SliceFile) Lock(lock vfs.LockLevel) error { return nil }
|
||||
func (*SliceFile) Lock(lock vfs.LockLevel) error {
|
||||
// notest // not concurrency safe
|
||||
return sqlite3.IOERR_LOCK
|
||||
}
|
||||
|
||||
// Unlock implements [vfs.File].
|
||||
func (*SliceFile) Unlock(lock vfs.LockLevel) error { return nil }
|
||||
func (*SliceFile) Unlock(lock vfs.LockLevel) error {
|
||||
// notest // not concurrency safe
|
||||
return sqlite3.IOERR_UNLOCK
|
||||
}
|
||||
|
||||
// CheckReservedLock implements [vfs.File].
|
||||
func (*SliceFile) CheckReservedLock() (bool, error) {
|
||||
// notest // OPEN_MEMORY
|
||||
// notest // not concurrency safe
|
||||
return false, sqlite3.IOERR_CHECKRESERVEDLOCK
|
||||
}
|
||||
|
||||
// SectorSize implements [vfs.File].
|
||||
func (*SliceFile) SectorSize() int {
|
||||
// notest // IOCAP_POWERSAFE_OVERWRITE
|
||||
// notest // safe default
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,14 @@ func UnwrapFile[T vfs.File](f vfs.File) (_ T, _ bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// WrapOpen helps wrap [vfs.VFS].
|
||||
func WrapOpen(f vfs.VFS, name string, flags vfs.OpenFlag) (file vfs.File, _ vfs.OpenFlag, err error) {
|
||||
if f, ok := f.(vfs.VFSFilename); name == "" && ok {
|
||||
return f.OpenFilename(nil, flags)
|
||||
}
|
||||
return f.Open(name, flags)
|
||||
}
|
||||
|
||||
// WrapOpenFilename helps wrap [vfs.VFSFilename].
|
||||
func WrapOpenFilename(f vfs.VFS, name *vfs.Filename, flags vfs.OpenFlag) (file vfs.File, _ vfs.OpenFlag, err error) {
|
||||
if f, ok := f.(vfs.VFSFilename); ok {
|
||||
|
||||
Reference in New Issue
Block a user