Files
sqlite3/sqlite3vfs/api.go

72 lines
2.1 KiB
Go
Raw Normal View History

2023-05-19 13:47:12 +01:00
// Package sqlite3vfs wraps the C SQLite VFS API.
2023-05-17 14:04:00 +01:00
package sqlite3vfs
2023-05-19 13:47:12 +01:00
// A VFS defines the interface between the SQLite core and the underlying operating system.
//
2023-05-19 19:47:43 +01:00
// Use sqlite3.ErrorCode or sqlite3.ExtendedErrorCode to return specific error codes to SQLite.
2023-05-19 14:45:40 +01:00
//
2023-05-19 13:47:12 +01:00
// https://www.sqlite.org/c3ref/vfs.html
2023-05-17 14:04:00 +01:00
type VFS interface {
Open(name string, flags OpenFlag) (File, OpenFlag, error)
2023-05-18 01:34:54 +01:00
Delete(name string, syncDir bool) error
2023-05-17 14:04:00 +01:00
Access(name string, flags AccessFlag) (bool, error)
FullPathname(name string) (string, error)
}
2023-05-19 13:47:12 +01:00
// A File represents an open file in the OS interface layer.
//
2023-05-19 19:47:43 +01:00
// Use sqlite3.ErrorCode or sqlite3.ExtendedErrorCode to return specific error codes to SQLite.
2023-05-19 14:45:40 +01:00
// In particular, sqlite3.BUSY is necessary to correctly implement lock methods.
//
2023-05-19 13:47:12 +01:00
// https://www.sqlite.org/c3ref/io_methods.html
2023-05-17 14:04:00 +01:00
type File interface {
Close() error
ReadAt(p []byte, off int64) (n int, err error)
WriteAt(p []byte, off int64) (n int, err error)
Truncate(size int64) error
2023-05-18 01:34:54 +01:00
Sync(flags SyncFlag) error
2023-05-23 16:34:09 +01:00
Size() (int64, error)
2023-05-18 01:34:54 +01:00
Lock(lock LockLevel) error
Unlock(lock LockLevel) error
2023-05-17 14:04:00 +01:00
CheckReservedLock() (bool, error)
2023-05-18 16:00:34 +01:00
SectorSize() int
2023-05-19 02:00:16 +01:00
DeviceCharacteristics() DeviceCharacteristic
}
2023-05-19 13:47:12 +01:00
// FileLockState extends [File] to implement the
// SQLITE_FCNTL_LOCKSTATE file control opcode.
//
// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html
2023-05-19 02:00:16 +01:00
type FileLockState interface {
File
LockState() LockLevel
}
2023-05-19 19:47:43 +01:00
// FileSizeHint extends [File] to implement the
2023-05-19 13:47:12 +01:00
// SQLITE_FCNTL_SIZE_HINT file control opcode.
//
// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html
2023-05-19 02:00:16 +01:00
type FileSizeHint interface {
File
SizeHint(size int64) error
}
2023-05-19 19:47:43 +01:00
// FileHasMoved extends [File] to implement the
2023-05-19 13:47:12 +01:00
// SQLITE_FCNTL_HAS_MOVED file control opcode.
//
// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html
2023-05-19 02:00:16 +01:00
type FileHasMoved interface {
File
HasMoved() (bool, error)
}
2023-05-19 19:47:43 +01:00
// FilePowersafeOverwrite extends [File] to implement the
2023-05-19 13:47:12 +01:00
// SQLITE_FCNTL_POWERSAFE_OVERWRITE file control opcode.
//
// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html
2023-05-19 02:00:16 +01:00
type FilePowersafeOverwrite interface {
File
PowersafeOverwrite() bool
SetPowersafeOverwrite(bool)
2023-05-17 14:04:00 +01:00
}