fskeleton

package
v0.0.0-...-f99e4bb Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package fskeleton attempts to factor out the common code needed to implement fs.FS. It is optimised for small memory usage at rest.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

FS is safe for concurrent use from multiple goroutines. It should not be copied after creation.

func New

func New() *FS

func (*FS) CreateError

func (fsys *FS) CreateError(name string, id int64, err error, size int64, mode fs.FileMode, mtime time.Time) error

CreateError creates a regular file at the specified path.

When opened, the file will always returns the specified error from fs.File.Read. fs.File.Close will have no effect.

In common with the other new-file methods, any missing parent directories will be created implicitly. Implicit directories can later be made explicit (only once) with FS.Mkdir.

func (*FS) CreateReadCloser

func (fsys *FS) CreateReadCloser(name string, id int64, r func() (io.ReadCloser, error), size int64, mode fs.FileMode, mtime time.Time) error

CreateReadCloser creates a regular file at the specified path.

When opened, the file will implement the bare minimum of fs.File.

In common with the other new-file methods, any missing parent directories will be created implicitly. Implicit directories can later be made explicit (only once) with FS.Mkdir.

func (*FS) CreateReader

func (fsys *FS) CreateReader(name string, id int64, r func() (io.Reader, error), size int64, mode fs.FileMode, mtime time.Time) error

CreateReader creates a regular file at the specified path.

When opened, the file will implement the bare minimum of fs.File. fs.File.Close will have no effect.

In common with the other new-file methods, any missing parent directories will be created implicitly. Implicit directories can later be made explicit (only once) with FS.Mkdir.

func (*FS) CreateReaderAt

func (fsys *FS) CreateReaderAt(name string, id int64, r io.ReaderAt, size int64, mode fs.FileMode, mtime time.Time) error

CreateReadCloser creates a regular file at the specified path.

When opened, the file will satisfy io.ReaderAt and io.ReadSeeker.

In common with the other new-file methods, any missing parent directories will be created implicitly. Implicit directories can later be made explicit (only once) with FS.Mkdir.

func (*FS) Lstat

func (fsys *FS) Lstat(name string) (info fs.FileInfo, err error)

Lstat returns a FileInfo describing the named file. If the file is a symlink, the returned FileInfo describes the symbolic link, not the linked file.

func (*FS) Mkdir

func (fsys *FS) Mkdir(name string, id int64, mode fs.FileMode, mtime time.Time) error

Mkdir creates a directory at the specified path.

In common with the other new-file methods, any missing parent directories will be created implicitly. Implicit directories can later be made explicit (only once) with FS.Mkdir.

func (*FS) NoMore

func (fsys *FS) NoMore()

NoMore prevents all future Create*() calls, which will fail with an error wrapping fs.ErrPermission.

NoMore unblocks any blocked fs.ReadDirFile.ReadDir calls.

func (*FS) Open

func (fsys *FS) Open(name string) (f fs.File, err error)

Open opens the named file.

func (fsys *FS) ReadLink(name string) (target string, err error)

ReadLink returns the destination of the named symbolic link.

func (*FS) Stat

func (fsys *FS) Stat(name string) (info fs.FileInfo, err error)

Stat returns a FileInfo describing the named file.

func (fsys *FS) Symlink(name string, id int64, target string, mode fs.FileMode, mtime time.Time) error

Symlink creates a symbolic link at the specified path.

In common with the other new-file methods, any missing parent directories will be created implicitly. Implicit directories can later be made explicit (only once) with FS.Mkdir.

The target argument must be an absolute path satisfying fs.ValidPath.

func (*FS) Walk

func (fsys *FS) Walk(waitFull bool) iter.Seq2[fmt.Stringer, fs.FileMode]

Walk iterates through all the paths in the filesystem, in the order they were created. This implies that directories are listed before their contents.

It is optional to block until a call to FS.NoMore.

type FileInfo

type FileInfo interface {
	fs.FileInfo
	ID() int64
}

FileInfo will always be satisfied wherever fs.FileInfo is satisfied.