memfs

package
v0.0.0-...-607911e Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOutOfRange = errors.New("Out of range")

Functions

func AddToMemDir

func AddToMemDir(dir *FileData, f *FileData)

func ChangeFileName

func ChangeFileName(f *FileData, newname string)

func InitializeDir

func InitializeDir(d *FileData)

func RemoveFromMemDir

func RemoveFromMemDir(dir *FileData, f *FileData)

func SetGID

func SetGID(f *FileData, gid int)

func SetModTime

func SetModTime(f *FileData, mtime time.Time)

func SetMode

func SetMode(f *FileData, mode fs.FileMode)

func SetUID

func SetUID(f *FileData, uid int)

Types

type Dir

type Dir interface {
	Len() int
	Names() []string
	Files() []*FileData
	Add(*FileData)
	Remove(*FileData)
}

type DirMap

type DirMap map[string]*FileData

func (DirMap) Add

func (m DirMap) Add(f *FileData)

func (DirMap) Files

func (m DirMap) Files() (files []*FileData)

func (DirMap) Len

func (m DirMap) Len() int

func (DirMap) Names

func (m DirMap) Names() (names []string)

func (DirMap) Remove

func (m DirMap) Remove(f *FileData)

type FS

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

func New

func New() *FS

func (*FS) Chmod

func (m *FS) Chmod(name string, mode fs.FileMode) error

func (*FS) Chown

func (m *FS) Chown(name string, uid, gid int) error

func (*FS) Chtimes

func (m *FS) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*FS) Create

func (m *FS) Create(name string) (fs.File, error)

func (*FS) Mkdir

func (m *FS) Mkdir(name string, perm fs.FileMode) error

func (*FS) MkdirAll

func (m *FS) MkdirAll(path string, perm fs.FileMode) error

func (*FS) Open

func (m *FS) Open(name string) (fs.File, error)

func (*FS) OpenFile

func (m *FS) OpenFile(name string, flag int, perm fs.FileMode) (fs.File, error)

func (*FS) Remove

func (m *FS) Remove(name string) error

func (*FS) RemoveAll

func (m *FS) RemoveAll(path string) error

func (*FS) Rename

func (m *FS) Rename(oldname, newname string) error

func (*FS) Stat

func (m *FS) Stat(name string) (fs.FileInfo, error)

type File

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

func NewFileHandle

func NewFileHandle(data *FileData) *File

func NewROFileHandle

func NewROFileHandle(data *FileData) *File

func (*File) Close

func (f *File) Close() error

func (File) Data

func (f File) Data() *FileData

func (*File) Info

func (f *File) Info() *FileInfo

func (*File) Name

func (f *File) Name() string

func (*File) Open

func (f *File) Open() error

func (*File) Read

func (f *File) Read(b []byte) (n int, err error)

func (*File) ReadAt

func (f *File) ReadAt(b []byte, off int64) (n int, err error)

func (*File) ReadDir

func (f *File) ReadDir(n int) ([]fs.DirEntry, error)

func (*File) Readdir

func (f *File) Readdir(count int) (res []fs.FileInfo, err error)

func (*File) Readdirnames

func (f *File) Readdirnames(n int) (names []string, err error)

func (*File) Seek

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

func (*File) Stat

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

func (*File) Sync

func (f *File) Sync() error

func (*File) Truncate

func (f *File) Truncate(size int64) error

func (*File) Write

func (f *File) Write(b []byte) (n int, err error)

func (*File) WriteAt

func (f *File) WriteAt(b []byte, off int64) (n int, err error)

func (*File) WriteString

func (f *File) WriteString(s string) (ret int, err error)

type FileData

type FileData struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func CreateDir

func CreateDir(name string) *FileData

func CreateFile

func CreateFile(name string) *FileData

func (*FileData) Name

func (d *FileData) Name() string

type FileInfo

type FileInfo struct {
	*FileData
}

func GetFileInfo

func GetFileInfo(f *FileData) *FileInfo

func (*FileInfo) IsDir

func (s *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (s *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (s *FileInfo) Mode() fs.FileMode

func (*FileInfo) Name

func (s *FileInfo) Name() string

Implements fs.FileInfo

func (*FileInfo) Size

func (s *FileInfo) Size() int64

func (*FileInfo) Sys

func (s *FileInfo) Sys() interface{}

Jump to

Keyboard shortcuts

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