fsx

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package fsx provides filesystem interfaces and test implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(fsys FS, path string) bool

Exists reports whether path can be statted.

func IsDir

func IsDir(fsys FS, path string) bool

IsDir reports whether path exists in fsys and is a directory.

func IsFile

func IsFile(fsys FS, path string) bool

IsFile reports whether path exists in fsys and is a regular file.

Types

type FS

type FS interface {
	Stat(path string) (fs.FileInfo, error)
	ReadFile(path string) ([]byte, error)
	ReadDir(path string) ([]fs.DirEntry, error)
}

FS is the read-only filesystem surface used by pawn-project.

type Mem

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

Mem is a concurrent, in-memory FS. Paths use forward slashes.

func NewMem

func NewMem() *Mem

NewMem returns an empty in-memory filesystem containing only the root directory "/".

func (*Mem) AddDir

func (m *Mem) AddDir(p string) *Mem

AddDir creates path and any missing parent directories as directories.

func (*Mem) AddFile

func (m *Mem) AddFile(p string, content []byte) *Mem

AddFile creates path and any missing parent directories, then sets path's content.

func (*Mem) Paths

func (m *Mem) Paths() []string

Paths returns all stored paths in sorted order.

func (*Mem) ReadDir

func (m *Mem) ReadDir(p string) ([]fs.DirEntry, error)

func (*Mem) ReadFile

func (m *Mem) ReadFile(p string) ([]byte, error)

func (*Mem) RemoveAll

func (m *Mem) RemoveAll(p string) error

RemoveAll removes a path and everything below it.

func (*Mem) Rename

func (m *Mem) Rename(oldPath, newPath string) error

Rename moves a path and everything below it.

func (*Mem) Stat

func (m *Mem) Stat(p string) (fs.FileInfo, error)

type OS

type OS struct{}

OS implements FS against the real filesystem. The zero value is ready to use.

func (OS) ReadDir

func (OS) ReadDir(path string) ([]fs.DirEntry, error)

func (OS) ReadFile

func (OS) ReadFile(path string) ([]byte, error)

func (OS) Stat

func (OS) Stat(path string) (fs.FileInfo, error)

Jump to

Keyboard shortcuts

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