fs

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 1 Imported by: 2

Documentation

Overview

This package provides an interface to functions and structs in the standard io/fs package to facilitate mocking.

Index

Constants

View Source
const (
	ModeRegular fs.FileMode = 0

	ModeDir        = fs.ModeDir
	ModeAppend     = fs.ModeAppend
	ModeExclusive  = fs.ModeExclusive
	ModeTemporary  = fs.ModeTemporary
	ModeSymlink    = fs.ModeSymlink
	ModeDevice     = fs.ModeDevice
	ModeNamedPipe  = fs.ModeNamedPipe
	ModeSocket     = fs.ModeSocket
	ModeSetuid     = fs.ModeSetuid
	ModeSetgid     = fs.ModeSetgid
	ModeCharDevice = fs.ModeCharDevice
	ModeSticky     = fs.ModeSticky
	ModeIrregular  = fs.ModeIrregular

	ModeType = fs.ModeType
	ModePerm = fs.ModePerm
)

Variables

View Source
var (
	ErrInvalid    = fs.ErrInvalid
	ErrPermission = fs.ErrPermission
	ErrExist      = fs.ErrExist
	ErrNotExist   = fs.ErrNotExist
	ErrClosed     = fs.ErrClosed

	SkipAll = fs.SkipAll
	SkipDir = fs.SkipDir
)

Functions

func NewDirEntry added in v0.1.6

func NewDirEntry(de fs.DirEntry) dirEntryFacade

func NewFileMode added in v0.1.7

func NewFileMode(fm fs.FileMode) fileModeFacade

func NewFileSystem

func NewFileSystem() fileSystemFacade

Types

type DirEntry

type DirEntry interface {
	// Access to members variables:
	Name() string
	IsDir() bool
	Type() fs.FileMode
	Info() (fs.FileInfo, error)

	Format() string
}

func ToDirEntryList added in v0.1.6

func ToDirEntryList(in []fs.DirEntry) []DirEntry

type FS

type FS = fs.FS

type File

type File = fs.File

type FileInfo

type FileInfo = fs.FileInfo

type FileMode

type FileMode interface {
	IsRegular() bool
	IsDir() bool
	IsAppend() bool
	IsExclusive() bool
	IsTemporary() bool
	IsSymlink() bool
	IsDevice() bool
	IsNamedPipe() bool
	IsSocket() bool
	IsSetuid() bool
	IsSetgid() bool
	IsCharDevice() bool
	IsSticky() bool
	IsIrregular() bool

	Perm() FileMode
	String() string
	Type() FileMode
}

type FileSystem

type FileSystem interface {
	FormatDirEntry(DirEntry) string
	FormatFileInfo(FileInfo) string
	Glob(FileSystem, string) ([]string, error)
	ReadFile(FileSystem, string) ([]byte, error)
	ValidPath(string) bool
	WalkDir(FileSystem, string, WalkDirFunc) error

	// Constructors
	FileInfoToDirEntry(FileInfo) DirEntry
	ReadDir(FileSystem, string) ([]DirEntry, error)

	Sub(FileSystem, string) (FileSystem, error)

	Stat(FileSystem, string) (FileInfo, error)
}

The FileSystem interface provides access to all the functions and structs in the io/fs package. It is renamed to FileSystem, instead of FS, because the io/fs package already contains an interface named FS.

type GlobFS

type GlobFS = fs.GlobFS

type PathError

type PathError = fs.PathError

type ReadDirFS

type ReadDirFS = fs.ReadDirFS

type ReadDirFile

type ReadDirFile = fs.ReadDirFile

type ReadFileFS

type ReadFileFS = fs.ReadFileFS

type StatFS

type StatFS = fs.StatFS

type SubFS

type SubFS = fs.SubFS

type WalkDirFunc

type WalkDirFunc = fs.WalkDirFunc

Jump to

Keyboard shortcuts

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