-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
170 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// Package ioutil implements I/O utility functions. | ||
// Package ioutil implements I/O utilities. | ||
package ioutil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// Package osutil implements operating system utility functions. | ||
// Package osutil implements operating system utilities. | ||
package osutil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// Package vtabutil implements virtual filesystem utilities. | ||
package vfsutil | ||
|
||
import ( | ||
"github.com/ncruces/go-sqlite3" | ||
"github.com/ncruces/go-sqlite3/vfs" | ||
) | ||
|
||
// WrapSharedMemory helps wrap [vfs.FileSharedMemory]. | ||
func WrapSharedMemory(f vfs.File) vfs.SharedMemory { | ||
if f, ok := f.(vfs.FileSharedMemory); ok { | ||
return f.SharedMemory() | ||
} | ||
return nil | ||
} | ||
|
||
// WrapChunkSize helps wrap [vfs.FileChunkSize]. | ||
func WrapChunkSize(f vfs.File, size int) { | ||
if f, ok := f.(vfs.FileChunkSize); ok { | ||
f.ChunkSize(size) | ||
} | ||
} | ||
|
||
// WrapSizeHint helps wrap [vfs.FileSizeHint]. | ||
func WrapSizeHint(f vfs.File, size int64) error { | ||
if f, ok := f.(vfs.FileSizeHint); ok { | ||
return f.SizeHint(size) | ||
} | ||
return sqlite3.NOTFOUND | ||
} | ||
|
||
// WrapHasMoved helps wrap [vfs.FileHasMoved]. | ||
func WrapHasMoved(f vfs.File) (bool, error) { | ||
if f, ok := f.(vfs.FileHasMoved); ok { | ||
return f.HasMoved() | ||
} | ||
return false, sqlite3.NOTFOUND | ||
} | ||
|
||
// WrapOverwrite helps wrap [vfs.FileOverwrite]. | ||
func WrapOverwrite(f vfs.File) error { | ||
if f, ok := f.(vfs.FileOverwrite); ok { | ||
return f.Overwrite() | ||
} | ||
return sqlite3.NOTFOUND | ||
} | ||
|
||
// WrapPersistentWAL helps wrap [vfs.FilePersistentWAL]. | ||
func WrapPersistentWAL(f vfs.File) bool { | ||
if f, ok := f.(vfs.FilePersistentWAL); ok { | ||
return f.PersistentWAL() | ||
} | ||
return false | ||
} | ||
|
||
// WrapSetPersistentWAL helps wrap [vfs.FilePersistentWAL]. | ||
func WrapSetPersistentWAL(f vfs.File, keepWAL bool) { | ||
if f, ok := f.(vfs.FilePersistentWAL); ok { | ||
f.SetPersistentWAL(keepWAL) | ||
} | ||
} | ||
|
||
// WrapPowersafeOverwrite helps wrap [vfs.FilePowersafeOverwrite]. | ||
func WrapPowersafeOverwrite(f vfs.File) bool { | ||
if f, ok := f.(vfs.FilePowersafeOverwrite); ok { | ||
return f.PowersafeOverwrite() | ||
} | ||
return false | ||
} | ||
|
||
// WrapSetPowersafeOverwrite helps wrap [vfs.FilePowersafeOverwrite]. | ||
func WrapSetPowersafeOverwrite(f vfs.File, psow bool) { | ||
if f, ok := f.(vfs.FilePowersafeOverwrite); ok { | ||
f.SetPowersafeOverwrite(psow) | ||
} | ||
} | ||
|
||
// WrapCommitPhaseTwo helps wrap [vfs.FileCommitPhaseTwo]. | ||
func WrapCommitPhaseTwo(f vfs.File) error { | ||
if f, ok := f.(vfs.FileCommitPhaseTwo); ok { | ||
return f.CommitPhaseTwo() | ||
} | ||
return sqlite3.NOTFOUND | ||
} | ||
|
||
// WrapBeginAtomicWrite helps wrap [vfs.FileBatchAtomicWrite]. | ||
func WrapBeginAtomicWrite(f vfs.File) error { | ||
if f, ok := f.(vfs.FileBatchAtomicWrite); ok { | ||
return f.BeginAtomicWrite() | ||
} | ||
return sqlite3.NOTFOUND | ||
} | ||
|
||
// WrapCommitAtomicWrite helps wrap [vfs.FileBatchAtomicWrite]. | ||
func WrapCommitAtomicWrite(f vfs.File) error { | ||
if f, ok := f.(vfs.FileBatchAtomicWrite); ok { | ||
return f.CommitAtomicWrite() | ||
} | ||
return sqlite3.NOTFOUND | ||
} | ||
|
||
// WrapRollbackAtomicWrite helps wrap [vfs.FileBatchAtomicWrite]. | ||
func WrapRollbackAtomicWrite(f vfs.File) error { | ||
if f, ok := f.(vfs.FileBatchAtomicWrite); ok { | ||
return f.RollbackAtomicWrite() | ||
} | ||
return sqlite3.NOTFOUND | ||
} | ||
|
||
// WrapCheckpointDone helps wrap [vfs.FileCheckpoint]. | ||
func WrapCheckpointDone(f vfs.File) error { | ||
if f, ok := f.(vfs.FileCheckpoint); ok { | ||
return f.CheckpointDone() | ||
} | ||
return sqlite3.NOTFOUND | ||
} | ||
|
||
// WrapCheckpointStart helps wrap [vfs.FileCheckpoint]. | ||
func WrapCheckpointStart(f vfs.File) error { | ||
if f, ok := f.(vfs.FileCheckpoint); ok { | ||
return f.CheckpointStart() | ||
} | ||
return sqlite3.NOTFOUND | ||
} | ||
|
||
// WrapPragma helps wrap [vfs.FilePragma]. | ||
func WrapPragma(f vfs.File, name, value string) (string, error) { | ||
if f, ok := f.(vfs.FilePragma); ok { | ||
return f.Pragma(name, value) | ||
} | ||
return "", sqlite3.NOTFOUND | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// Package vtabutil implements virtual table utility functions. | ||
// Package vtabutil implements virtual table utilities. | ||
package vtabutil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.