Artifact 9eb28b17dddd191c361cc55cc5f015f0584a4b1621eee12aa9fbe383cd61214c:
- File
simio/storage.go
— part of check-in
[f5744359d3]
at
2026-04-19 16:30:54
on branch trunk
— Initial open source release
libfossil is a pure-Go implementation of the Fossil SCM, reading and writing the same .fossil SQLite repository format as upstream Fossil.
This is the first public release of code that previously lived in a private repository. The module path is github.com/danmestas/libfossil and the binary is named libfossil to avoid $PATH collisions with upstream fossil.
Included: - Repo lifecycle (create, clone), checkout/checkin, timeline, merge, diff, annotate, shun, tag, branch, bisect, stash, undo/redo - Sync-over-HTTP protocol (client and handler) - Two SQLite drivers: modernc (pure Go, default) and ncruces (wasm-capable) - Observer interfaces (SyncObserver, CheckoutObserver) with an optional OpenTelemetry implementation in observer/otel (separate submodule) - Deterministic simulation testing harness with BUGGIFY fault injection - Kong-based embeddable CLI under cli/ and a standalone binary under cmd/libfossil/ (user: [email protected], size: 1326) [annotate] [blame] [check-ins using]
package simio import ( "io/fs" "os" "time" ) // Storage abstracts filesystem operations for WASM portability. type Storage interface { Stat(path string) (os.FileInfo, error) Remove(path string) error MkdirAll(path string, perm os.FileMode) error ReadFile(path string) ([]byte, error) WriteFile(path string, data []byte, perm os.FileMode) error ReadDir(path string) ([]fs.DirEntry, error) Chtimes(path string, atime, mtime time.Time) error } // OSStorage delegates to the os package. Used in production and WASI. type OSStorage struct{} func (OSStorage) Stat(path string) (os.FileInfo, error) { return os.Stat(path) } func (OSStorage) Remove(path string) error { return os.Remove(path) } func (OSStorage) MkdirAll(path string, perm os.FileMode) error { return os.MkdirAll(path, perm) } func (OSStorage) ReadFile(path string) ([]byte, error) { return os.ReadFile(path) } func (OSStorage) WriteFile(path string, data []byte, perm os.FileMode) error { return os.WriteFile(path, data, perm) } func (OSStorage) ReadDir(path string) ([]fs.DirEntry, error) { return os.ReadDir(path) } func (OSStorage) Chtimes(path string, atime, mtime time.Time) error { return os.Chtimes(path, atime, mtime) }