fskeleton

package
v0.0.0-...-5b07d03 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 13 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

View Source
const SizeUnknown = -1

Variables

View Source
var ErrSizeUnknown = errors.New("file created with SizeUnknown")

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) BornSizeUnknown

func (fsys *FS) BornSizeUnknown(name internpath.Path) (bool, error)

func (*FS) CreateError

func (fsys *FS) CreateError(name string, id int64, err error, size int64, perms 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, perms 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. If SizeUnknown is specified, then the file's Stat call will return SizeUnknown until the first time the first time the underlying data source is read through to EOF, after which it will return the EOF.

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, perms 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. If SizeUnknown is specified, then the file's Stat call will return SizeUnknown until the first time the first time the underlying data source is read through to EOF, after which it will return the EOF.

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, perms 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) GetBozo

func (fsys *FS) GetBozo(name internpath.Path) (bozo uint16, ok bool)

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, perms 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) SetBozo

func (fsys *FS) SetBozo(name internpath.Path, bozo uint16) (prev uint16, ok bool)

SetBozo stores a small integer in the file info. It is intended for use by the consumer of the filesystem, not the creator.

func (*FS) SetSize

func (fsys *FS) SetSize(name internpath.Path, size int64) error

SetSize sets the size of a regular file that has already been created with SizeUnknown.

func (*FS) Size

func (fsys *FS) Size(name internpath.Path) (int64, error)

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, perms 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.

Jump to

Keyboard shortcuts

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