filesystem

package
v0.0.0-...-6c293db Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReadOnly = errors.New("this file is readonly")
View Source
var OS = &osFS{}

Functions

func Exists

func Exists(fs FS, path string) bool

func ReadAll

func ReadAll(fs FS, path string) ([]byte, error)

func ReadDir

func ReadDir(fs FS, dirname string) ([]os.FileInfo, error)

func WritePath

func WritePath(fs FS, path string, data []byte) error

Types

type FS

type FS interface {
	Open(name string) (File, error)
	OpenIfExists(name string) (File, error)
	OpenForWrite(name string) (File, error)
	OpenForAppend(name string) (File, error)
	Stat(name string) (os.FileInfo, error)
	Write(name string, data []byte) error
	Append(name string, data []byte) error
	AppendPath(name string, data []byte) error
	Rename(oldPath, newPath string) error
	RemoveAll(path string) error
	Mkdir(name string) error
	MkdirAll(name string) error
	Chdir(dir string) error
	Getwd() (string, error)
	Abs(name string) (string, error)
	SetHome(name string) error
}

type File

type File interface {
	io.Closer
	io.Reader
	io.ReaderAt
	io.Seeker
	io.WriterAt
	Stat() (os.FileInfo, error)
	Readdir(n int) ([]os.FileInfo, error)
	io.Writer
}

type ReadOnlyFS

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

ReadOnlyFS implements fileSystem that serves a directory as root

func NewReadOnlyFS

func NewReadOnlyFS(fs FS) *ReadOnlyFS

func (*ReadOnlyFS) Abs

func (r *ReadOnlyFS) Abs(name string) (string, error)

func (*ReadOnlyFS) Append

func (r *ReadOnlyFS) Append(name string, data []byte) error

func (*ReadOnlyFS) AppendPath

func (r *ReadOnlyFS) AppendPath(name string, data []byte) error

func (*ReadOnlyFS) Chdir

func (r *ReadOnlyFS) Chdir(name string) error

func (*ReadOnlyFS) Getwd

func (r *ReadOnlyFS) Getwd() (string, error)

func (*ReadOnlyFS) Mkdir

func (r *ReadOnlyFS) Mkdir(name string) error

func (*ReadOnlyFS) MkdirAll

func (r *ReadOnlyFS) MkdirAll(name string) error

func (*ReadOnlyFS) Open

func (r *ReadOnlyFS) Open(name string) (File, error)

func (*ReadOnlyFS) OpenForAppend

func (r *ReadOnlyFS) OpenForAppend(name string) (File, error)

func (*ReadOnlyFS) OpenForWrite

func (r *ReadOnlyFS) OpenForWrite(name string) (File, error)

func (*ReadOnlyFS) OpenIfExists

func (r *ReadOnlyFS) OpenIfExists(name string) (File, error)

func (*ReadOnlyFS) RemoveAll

func (r *ReadOnlyFS) RemoveAll(name string) error

func (*ReadOnlyFS) Rename

func (r *ReadOnlyFS) Rename(oldPath, newPath string) error

func (*ReadOnlyFS) SetHome

func (r *ReadOnlyFS) SetHome(name string) error

Sets the home directory

func (*ReadOnlyFS) Stat

func (r *ReadOnlyFS) Stat(name string) (os.FileInfo, error)

func (*ReadOnlyFS) Write

func (r *ReadOnlyFS) Write(name string, data []byte) error

type RestrictedFS

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

RestrictedFS implements fileSystem that serves a directory as root

func NewRestrictedFS

func NewRestrictedFS(fs FS) (*RestrictedFS, error)

func (*RestrictedFS) Abs

func (r *RestrictedFS) Abs(name string) (string, error)

func (*RestrictedFS) AddToBlacklist

func (r *RestrictedFS) AddToBlacklist(name string) error

func (*RestrictedFS) AddToWhitelist

func (r *RestrictedFS) AddToWhitelist(name string) error

func (*RestrictedFS) Append

func (r *RestrictedFS) Append(name string, data []byte) error

func (*RestrictedFS) AppendPath

func (r *RestrictedFS) AppendPath(name string, data []byte) error

func (*RestrictedFS) Chdir

func (r *RestrictedFS) Chdir(name string) error

func (*RestrictedFS) Getwd

func (r *RestrictedFS) Getwd() (string, error)

func (*RestrictedFS) Mkdir

func (r *RestrictedFS) Mkdir(name string) error

func (*RestrictedFS) MkdirAll

func (r *RestrictedFS) MkdirAll(name string) error

func (*RestrictedFS) Open

func (r *RestrictedFS) Open(name string) (File, error)

func (*RestrictedFS) OpenForAppend

func (r *RestrictedFS) OpenForAppend(name string) (File, error)

func (*RestrictedFS) OpenForWrite

func (r *RestrictedFS) OpenForWrite(name string) (File, error)

func (*RestrictedFS) OpenIfExists

func (r *RestrictedFS) OpenIfExists(name string) (File, error)

func (*RestrictedFS) RemoveAll

func (r *RestrictedFS) RemoveAll(name string) error

func (*RestrictedFS) Rename

func (r *RestrictedFS) Rename(oldPath, newPath string) error

func (*RestrictedFS) SetHome

func (r *RestrictedFS) SetHome(name string) error

Sets the home directory

func (*RestrictedFS) Stat

func (r *RestrictedFS) Stat(name string) (os.FileInfo, error)

func (*RestrictedFS) Write

func (r *RestrictedFS) Write(name string, data []byte) error

type RootedFS

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

RootedFS implements fileSystem that serves a directory as root

func NewRootedFS

func NewRootedFS(root string, fs FS) (*RootedFS, error)

func (*RootedFS) Abs

func (r *RootedFS) Abs(name string) (string, error)

func (*RootedFS) Append

func (r *RootedFS) Append(name string, data []byte) error

func (*RootedFS) AppendPath

func (r *RootedFS) AppendPath(name string, data []byte) error

func (*RootedFS) Chdir

func (r *RootedFS) Chdir(name string) error

func (*RootedFS) Getwd

func (r *RootedFS) Getwd() (string, error)

func (*RootedFS) Mkdir

func (r *RootedFS) Mkdir(name string) error

func (*RootedFS) MkdirAll

func (r *RootedFS) MkdirAll(name string) error

func (*RootedFS) Open

func (r *RootedFS) Open(name string) (File, error)

func (*RootedFS) OpenForAppend

func (r *RootedFS) OpenForAppend(name string) (File, error)

func (*RootedFS) OpenForWrite

func (r *RootedFS) OpenForWrite(name string) (File, error)

func (*RootedFS) OpenIfExists

func (r *RootedFS) OpenIfExists(name string) (File, error)

func (*RootedFS) RemoveAll

func (r *RootedFS) RemoveAll(name string) error

func (*RootedFS) Rename

func (r *RootedFS) Rename(oldPath, newPath string) error

func (*RootedFS) SetHome

func (r *RootedFS) SetHome(name string) error

Sets the home directory

func (*RootedFS) Stat

func (r *RootedFS) Stat(name string) (os.FileInfo, error)

func (*RootedFS) Write

func (r *RootedFS) Write(name string, data []byte) error

type VirtualFS

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

A tree of virtual files. A virtual file can be a directory or a individual file.

func NewVirtualFS

func NewVirtualFS() *VirtualFS

func (*VirtualFS) Abs

func (v *VirtualFS) Abs(name string) (string, error)

func (*VirtualFS) Append

func (v *VirtualFS) Append(name string, data []byte) error

func (*VirtualFS) AppendPath

func (v *VirtualFS) AppendPath(path string, data []byte) error

func (*VirtualFS) Chdir

func (v *VirtualFS) Chdir(name string) error

func (*VirtualFS) CopyAt

func (v *VirtualFS) CopyAt(dst, src string, fs FS) error

Copy copies recursively path src into dst.

func (*VirtualFS) Getwd

func (v *VirtualFS) Getwd() (string, error)

func (*VirtualFS) Mkdir

func (v *VirtualFS) Mkdir(name string) error

func (*VirtualFS) MkdirAll

func (v *VirtualFS) MkdirAll(name string) error

func (*VirtualFS) Open

func (v *VirtualFS) Open(name string) (File, error)

func (*VirtualFS) OpenForAppend

func (v *VirtualFS) OpenForAppend(name string) (File, error)

func (*VirtualFS) OpenForWrite

func (v *VirtualFS) OpenForWrite(name string) (File, error)

func (*VirtualFS) OpenIfExists

func (v *VirtualFS) OpenIfExists(name string) (File, error)

func (*VirtualFS) PrintPaths

func (v *VirtualFS) PrintPaths()

func (*VirtualFS) RemoveAll

func (v *VirtualFS) RemoveAll(name string) error

func (*VirtualFS) Rename

func (v *VirtualFS) Rename(oldPath, newPath string) error

func (*VirtualFS) SetHome

func (v *VirtualFS) SetHome(name string) error

func (*VirtualFS) Stat

func (v *VirtualFS) Stat(name string) (os.FileInfo, error)

func (*VirtualFS) Write

func (v *VirtualFS) Write(name string, data []byte) error

Jump to

Keyboard shortcuts

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