rootfs

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 13 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDir added in v0.20.0

func ClearDir(dir path.Local) error

func CreateFile added in v0.20.0

func CreateFile(f path.Local, bt []byte) error

CreateFile does return an error, if the file already exists or if the parent directory does not exist

func CreateFileFrom added in v0.20.0

func CreateFileFrom(f path.Local, rd io.Reader) error

func Delete added in v0.20.0

func Delete(p path.Local, recursive bool) error

func DirSize added in v0.20.0

func DirSize(dir path.Local) (size int64)

DirSize returns the size of the given directory. If the given path is not a directory or any error occurs, -1 is returned. If the given dir is empty, 0 is returned. TODO test

func Drive added in v0.20.0

func Drive(p path.Local, recursive bool) (path.Local, error)

func Exists added in v0.20.0

func Exists(p path.Local) bool

func FreeSpace added in v0.20.0

func FreeSpace(p path.Local) int64

func GetMode added in v0.20.0

func GetMode(p path.Local) (fs.FileMode, error)

func Glob added in v0.20.0

func Glob(pattern string) (matches []path.Local, err error)

func IsEmpty added in v0.20.0

func IsEmpty(dir path.Local) bool

IsEmpty returns, if the given dir is empty or does not exist or is not a directory, but a file.

func MkDir added in v0.20.0

func MkDir(p path.Local) error

func MkDirAll added in v0.20.0

func MkDirAll(p path.Local) error

func MkDirTmp added in v0.20.0

func MkDirTmp(pattern string) (dir path.Local, err error)

func ModTime added in v0.20.0

func ModTime(p path.Local) (time.Time, error)

func Move added in v0.20.0

func Move(src path.Local, targetDir path.Local) error

func MustPath added in v0.17.0

func MustPath(p string) (r path.Relative)

MustPath is like ParsePath, only that it panics, if the given path is not valid

func MustWD added in v0.17.0

func MustWD() (r path.Relative)

MustWD is like ParseWD, but panics on error

func ParsePath added in v0.17.0

func ParsePath(p string) (r path.Relative, err error)

ParsePath parses an existing local path and returns a normalized path that is relative to rootfs the path might be absolute or relative (than it is relative to the current working directory) the given path must not end in a slash. if p must not be an empty string, or .

func ParseWD added in v0.17.0

func ParseWD() (r path.Relative, err error)

ParseWD parses the working dir and returns a normalized path that is relative to rootfs

func ReadDirNames added in v0.20.0

func ReadDirNames(dir path.Local) ([]string, error)

ReadDirNames returns the names of the dirs and files in a directory and returns them

func ReadDirPaths added in v0.20.0

func ReadDirPaths(dir path.Local) ([]path.Local, error)

ReadDirPaths returns the full paths (including dir) of the files and folders inside dir

func ReadFile added in v0.20.0

func ReadFile(f path.Local) ([]byte, error)

func ReadSeeker added in v0.20.0

func ReadSeeker(p path.Local) (fs.ReadSeekCloser, error)

func Reader added in v0.20.0

func Reader(p path.Local) (io.ReadCloser, error)

func Rename added in v0.20.0

func Rename(p path.Local, name string) error

func SetMode added in v0.20.0

func SetMode(p path.Local, m fs.FileMode) error

func Size added in v0.20.0

func Size(file path.Local) int64

func Write added in v0.20.0

func Write(p path.Local, rd io.ReadCloser, inbetween bool) error

func WriteFile added in v0.20.0

func WriteFile(f path.Local, bt []byte, recursive bool) error

func WriteFileFrom added in v0.20.0

func WriteFileFrom(f path.Local, rd io.Reader, recursive bool) error

func WriteTmpFile added in v0.20.0

func WriteTmpFile(parentDir path.Local, pattern string, data []byte) (path.Local, error)

func WriteWithMode added in v0.20.0

func WriteWithMode(p path.Local, data io.ReadCloser, m fs.FileMode, recursive bool) error

Types

type FS

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

func New

func New() (*FS, error)

func NewMock added in v0.17.0

func NewMock() (*FS, error)

func (*FS) Abs

func (fsys *FS) Abs(p path.Relative) path.Absolute

func (FS) Delete added in v0.17.0

func (fsys FS) Delete(p path.Relative, recursive bool) (err error)

func (FS) Drive added in v0.17.0

func (fsys FS) Drive(p path.Relative) (l path.Local, err error)

func (FS) Exists added in v0.17.0

func (fsys FS) Exists(p path.Relative) bool

func (FS) FreeSpace added in v0.17.0

func (fsys FS) FreeSpace(r path.Relative) int64

func (FS) GetMode added in v0.17.0

func (fsys FS) GetMode(p path.Relative) (m fs.FileMode, err error)

should not return mode for a mountpoint (error (not implemented)), should return error (not implemented), if there is no fallback

func (FS) Glob added in v0.17.0

func (fsys FS) Glob(pattern string) (matches []path.Relative, err error)

func (FS) MkDirTmp added in v0.18.1

func (fsys FS) MkDirTmp(parentDir path.Relative, pattern string) (dir path.Relative, err error)

MkDirTmp creates a temporary directory inside the given parentDir if the parentDir is root, os.TempDir() is used as a parent, in each case the resulting dir must exist

func (FS) ModTime added in v0.17.0

func (fsys FS) ModTime(p path.Relative) (t time.Time, err error)

func (FS) Move added in v0.17.0

func (fsys FS) Move(src, trgtDir path.Relative) (err error)

func (FS) ReadSeeker added in v0.17.0

func (fsys FS) ReadSeeker(r path.Relative) (fs.ReadSeekCloser, error)

func (FS) Reader added in v0.17.0

func (fsys FS) Reader(p path.Relative) (io.ReadCloser, error)

func (FS) Rename added in v0.17.0

func (fsys FS) Rename(p path.Relative, name string) (err error)

func (FS) SetMode added in v0.17.0

func (fsys FS) SetMode(p path.Relative, m fs.FileMode) (err error)

func (FS) Size added in v0.17.0

func (fsys FS) Size(file path.Relative) int64

func (FS) Write added in v0.17.0

func (fsys FS) Write(p path.Relative, rd io.ReadCloser, inbetween bool) (err error)

func (FS) WriteSeeker added in v0.21.0

func (fsys FS) WriteSeeker(r path.Relative) (fs.WriteSeekCloser, error)

func (FS) WriteTmpFile added in v0.18.1

func (fsys FS) WriteTmpFile(parentDir path.Relative, pattern string, data []byte) (file path.Relative, err error)

WriteTmpFile writes to a temporary file inside the given parentDir if the parentDir is root, os.TempDir() is used as a parent, in each case the resulting dir must exist

func (FS) WriteWithMode added in v0.17.0

func (fsys FS) WriteWithMode(p path.Relative, data io.ReadCloser, m fs.FileMode, recursive bool) (err error)

Jump to

Keyboard shortcuts

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