context fs

This commit is contained in:
royalcat 2024-03-21 00:47:51 +03:00
parent fd3beea874
commit 7b1863109c
25 changed files with 593 additions and 349 deletions
src/host/vfs

View file

@ -1,12 +1,13 @@
package vfs
import (
"context"
"errors"
"io/fs"
"path"
"time"
"git.kmsign.ru/royalcat/tstor/src/iio"
"git.kmsign.ru/royalcat/tstor/pkg/ctxio"
)
type File interface {
@ -14,7 +15,9 @@ type File interface {
Size() int64
Stat() (fs.FileInfo, error)
iio.Reader
ctxio.Reader
ctxio.ReaderAt
ctxio.Closer
}
var ErrNotImplemented = errors.New("not implemented")
@ -23,14 +26,14 @@ type Filesystem interface {
// Open opens the named file for reading. If successful, methods on the
// returned file can be used for reading; the associated file descriptor has
// mode O_RDONLY.
Open(filename string) (File, error)
Open(ctx context.Context, filename string) (File, error)
// ReadDir reads the directory named by dirname and returns a list of
// directory entries.
ReadDir(path string) ([]fs.DirEntry, error)
ReadDir(ctx context.Context, path string) ([]fs.DirEntry, error)
Stat(filename string) (fs.FileInfo, error)
Unlink(filename string) error
Stat(ctx context.Context, filename string) (fs.FileInfo, error)
Unlink(ctx context.Context, filename string) error
fs.DirEntry
}