fsext

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: AGPL-3.0 Imports: 8 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPathNeverRequestedBefore = errors.New("path never requested before")

ErrPathNeverRequestedBefore represent an error when path never opened/requested before

Functions

func NewCacheOnReadFs

func NewCacheOnReadFs(base, layer afero.Fs, cacheTime time.Duration) afero.Fs

NewCacheOnReadFs returns a new CacheOnReadFs

func Walk

func Walk(fs afero.Fs, root string, walkFn filepath.WalkFunc) error

Walk implements afero.Walk, but in a way that it doesn't loop to infinity and doesn't have problems if a given path part looks like a windows volume name

Types

type CacheLayerGetter added in v0.36.0

type CacheLayerGetter interface {
	GetCachingFs() afero.Fs
}

CacheLayerGetter provide a direct access to a cache layer

type CacheOnReadFs

type CacheOnReadFs struct {
	afero.Fs
	// contains filtered or unexported fields
}

CacheOnReadFs is wrapper around afero.CacheOnReadFs with the ability to return the filesystem that is used as cache

func (*CacheOnReadFs) AllowOnlyCached added in v0.36.0

func (c *CacheOnReadFs) AllowOnlyCached()

AllowOnlyCached enables the cached only mode of the CacheOnReadFs

func (*CacheOnReadFs) GetCachingFs

func (c *CacheOnReadFs) GetCachingFs() afero.Fs

GetCachingFs returns the afero.Fs being used for cache

func (*CacheOnReadFs) Open added in v0.36.0

func (c *CacheOnReadFs) Open(name string) (afero.File, error)

Open opens file and track the history of opened files if CacheOnReadFs is in the opened only mode it should return an error if file wasn't open before

func (*CacheOnReadFs) Stat added in v0.36.0

func (c *CacheOnReadFs) Stat(path string) (os.FileInfo, error)

Stat returns a FileInfo describing the named file, or an error, if any happens. if CacheOnReadFs is in the opened only mode it should return an error if path wasn't open before

type ChangePathFile

type ChangePathFile struct {
	afero.File
	// contains filtered or unexported fields
}

ChangePathFile is a file from ChangePathFs

func (*ChangePathFile) Name

func (f *ChangePathFile) Name() string

Name Returns the name of the file

type ChangePathFs

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

ChangePathFs is a filesystem that wraps another afero.Fs and changes all given paths from all file and directory names, with a function, before calling the same method on the wrapped afero.Fs. Heavily based on afero.BasePathFs

func NewChangePathFs

func NewChangePathFs(source afero.Fs, fn ChangePathFunc) *ChangePathFs

NewChangePathFs return a ChangePathFs where all paths will be change with the provided funcs

func NewTrimFilePathSeparatorFs

func NewTrimFilePathSeparatorFs(source afero.Fs) *ChangePathFs

NewTrimFilePathSeparatorFs is ChangePathFs that trims a Afero.FilePathSeparator from all paths Heavily based on afero.BasePathFs

func (*ChangePathFs) Chmod

func (b *ChangePathFs) Chmod(name string, mode os.FileMode) (err error)

Chmod changes the mode of the named file to mode.

func (*ChangePathFs) Chown added in v0.35.0

func (b *ChangePathFs) Chown(name string, uid, gid int) error

Chown changes the uid and gid of the named file.

func (*ChangePathFs) Chtimes

func (b *ChangePathFs) Chtimes(name string, atime, mtime time.Time) (err error)

Chtimes changes the access and modification times of the named file

func (*ChangePathFs) Create

func (b *ChangePathFs) Create(name string) (f afero.File, err error)

Create creates a file in the filesystem, returning the file and an error, if any happens

func (*ChangePathFs) LstatIfPossible

func (b *ChangePathFs) LstatIfPossible(name string) (os.FileInfo, bool, error)

LstatIfPossible implements the afero.Lstater interface

func (*ChangePathFs) Mkdir

func (b *ChangePathFs) Mkdir(name string, mode os.FileMode) (err error)

Mkdir creates a directory in the filesystem, return an error if any happens.

func (*ChangePathFs) MkdirAll

func (b *ChangePathFs) MkdirAll(name string, mode os.FileMode) (err error)

MkdirAll creates a directory path and all parents that does not exist yet.

func (*ChangePathFs) Name

func (b *ChangePathFs) Name() string

Name return the name of this FileSystem

func (*ChangePathFs) Open

func (b *ChangePathFs) Open(name string) (f afero.File, err error)

Open opens a file, returning it or an error, if any happens.

func (*ChangePathFs) OpenFile

func (b *ChangePathFs) OpenFile(name string, flag int, mode os.FileMode) (f afero.File, err error)

OpenFile opens a file using the given flags and the given mode.

func (*ChangePathFs) Remove

func (b *ChangePathFs) Remove(name string) (err error)

Remove removes a file identified by name, returning an error, if any happens.

func (*ChangePathFs) RemoveAll

func (b *ChangePathFs) RemoveAll(name string) (err error)

RemoveAll removes a directory path and any children it contains. It does not fail if the path does not exist (return nil).

func (*ChangePathFs) Rename

func (b *ChangePathFs) Rename(oldName, newName string) (err error)

Rename renames a file.

func (*ChangePathFs) Stat

func (b *ChangePathFs) Stat(name string) (fi os.FileInfo, err error)

Stat returns a FileInfo describing the named file, or an error, if any happens.

type ChangePathFunc

type ChangePathFunc func(name string) (path string, err error)

ChangePathFunc is the function that will be called by ChangePathFs to change the path

type OnlyCachedEnabler added in v0.36.0

type OnlyCachedEnabler interface {
	AllowOnlyCached()
}

OnlyCachedEnabler enables the mode of FS that allows to open already opened files (e.g. serve from cache only)

Jump to

Keyboard shortcuts

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