fskit

package
v0.0.0-...-b753801 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirFile

func DirFile(info *Node, entries ...fs.DirEntry) fs.File

func FileFS

func FileFS(file fs.File, name string) fs.FS

FileFS wraps a single fs.File as an fs.FS such that opening "." returns that file (not a directory).

func MatchPaths

func MatchPaths(paths []string, name string) (matches []string)

func NamedFS

func NamedFS(fsys fs.FS, name string) fs.FS

func SetData

func SetData(n *Node, data []byte)

func SetGid

func SetGid(n *Node, gid int)

func SetLogger

func SetLogger(n *Node, log *slog.Logger)

func SetModTime

func SetModTime(n *Node, modTime time.Time)

func SetMode

func SetMode(n *Node, mode fs.FileMode)

func SetName

func SetName(n *Node, name string)

func SetSize

func SetSize(n *Node, size int64)

func SetSys

func SetSys(n *Node, sys any)

func SetUid

func SetUid(n *Node, uid int)

func UnionDir

func UnionDir(name string, mode fs.FileMode, dirs ...fs.File) fs.File

Types

type DirIter

type DirIter struct {
	// contains filtered or unexported fields
}

func NewDirIter

func NewDirIter(fn func() ([]fs.DirEntry, error)) *DirIter

func (*DirIter) ReadDir

func (rdi *DirIter) ReadDir(n int) ([]fs.DirEntry, error)

type FuncFile

type FuncFile struct {
	Node      *Node
	ReadFunc  func(n *Node) error
	CloseFunc func(n *Node) error
	// contains filtered or unexported fields
}

func (*FuncFile) Close

func (f *FuncFile) Close() error

func (*FuncFile) Read

func (f *FuncFile) Read(b []byte) (int, error)

func (*FuncFile) ReadAt

func (f *FuncFile) ReadAt(b []byte, off int64) (int, error)

func (*FuncFile) Seek

func (f *FuncFile) Seek(offset int64, whence int) (int64, error)

no-op

func (*FuncFile) Stat

func (f *FuncFile) Stat() (fs.FileInfo, error)

func (*FuncFile) Write

func (f *FuncFile) Write(b []byte) (int, error)

type MapFS

type MapFS map[string]fs.FS

func (MapFS) Open

func (fsys MapFS) Open(name string) (fs.File, error)

func (MapFS) OpenContext

func (fsys MapFS) OpenContext(ctx context.Context, name string) (fs.File, error)

func (MapFS) ResolveFS

func (fsys MapFS) ResolveFS(ctx context.Context, name string) (fs.FS, string, error)

func (MapFS) Stat

func (fsys MapFS) Stat(name string) (fs.FileInfo, error)

func (MapFS) StatContext

func (fsys MapFS) StatContext(ctx context.Context, name string) (fs.FileInfo, error)

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node is used to create an fs.FileInfo, fs.DirEntry, or fs.FS.

func Entry

func Entry(name string, mode fs.FileMode, more ...any) *Node

func RawNode

func RawNode(attrs ...any) *Node

func (*Node) Data

func (n *Node) Data() []byte

func (*Node) Info

func (n *Node) Info() (fs.FileInfo, error)

func (*Node) IsDir

func (n *Node) IsDir() bool

func (*Node) Log

func (n *Node) Log() *slog.Logger

func (*Node) ModTime

func (n *Node) ModTime() time.Time

func (*Node) Mode

func (n *Node) Mode() fs.FileMode

func (*Node) Name

func (n *Node) Name() string

func (*Node) Open

func (n *Node) Open(name string) (fs.File, error)

func (*Node) OpenContext

func (n *Node) OpenContext(ctx context.Context, name string) (fs.File, error)

TODO: open sub nodes

func (*Node) Path

func (n *Node) Path() string

func (*Node) Reader

func (n *Node) Reader() io.Reader

func (*Node) Size

func (n *Node) Size() int64

func (*Node) String

func (n *Node) String() string

func (*Node) Sys

func (n *Node) Sys() any

func (*Node) Type

func (n *Node) Type() fs.FileMode

func (*Node) Writer

func (n *Node) Writer() io.Writer

type OpenFunc

type OpenFunc func(ctx context.Context, name string) (fs.File, error)

func (OpenFunc) Open

func (f OpenFunc) Open(name string) (fs.File, error)

func (OpenFunc) OpenContext

func (f OpenFunc) OpenContext(ctx context.Context, name string) (fs.File, error)

func (OpenFunc) OpenFile

func (f OpenFunc) OpenFile(name string, flag int, perm fs.FileMode) (fs.File, error)

type OverlayFile

type OverlayFile struct {
	Base    fs.File
	Overlay fs.File
	HideFn  func(name string) bool // if true, entry is hidden from readdir results
	// contains filtered or unexported fields
}

func (*OverlayFile) Close

func (f *OverlayFile) Close() error

func (*OverlayFile) Read

func (f *OverlayFile) Read(s []byte) (int, error)

func (*OverlayFile) ReadAt

func (f *OverlayFile) ReadAt(s []byte, o int64) (int, error)

func (*OverlayFile) ReadDir

func (f *OverlayFile) ReadDir(c int) ([]fs.DirEntry, error)

func (*OverlayFile) Seek

func (f *OverlayFile) Seek(o int64, w int) (pos int64, err error)

func (*OverlayFile) Stat

func (f *OverlayFile) Stat() (os.FileInfo, error)

func (*OverlayFile) Sync

func (f *OverlayFile) Sync() (err error)

func (*OverlayFile) Write

func (f *OverlayFile) Write(s []byte) (n int, err error)

func (*OverlayFile) WriteAt

func (f *OverlayFile) WriteAt(s []byte, o int64) (n int, err error)

type StreamFile

type StreamFile struct {
	io.Reader
	io.Writer
	io.Closer
	// contains filtered or unexported fields
}

func NewStreamFile

func NewStreamFile(r io.Reader, w io.Writer, c io.Closer, attrs ...any) *StreamFile

func (*StreamFile) Close

func (f *StreamFile) Close() error

func (*StreamFile) Identity

func (f *StreamFile) Identity() fs.ID

func (*StreamFile) Read

func (f *StreamFile) Read(p []byte) (int, error)

func (*StreamFile) Stat

func (f *StreamFile) Stat() (fs.FileInfo, error)

func (*StreamFile) Write

func (f *StreamFile) Write(p []byte) (int, error)

type UnionFS

type UnionFS []fs.FS

read-only union of filesystems

func (UnionFS) Open

func (f UnionFS) Open(name string) (fs.File, error)

func (UnionFS) OpenContext

func (f UnionFS) OpenContext(ctx context.Context, name string) (fs.File, error)

func (UnionFS) ResolveFS

func (f UnionFS) ResolveFS(ctx context.Context, name string) (fs.FS, string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL