Documentation ¶
Overview ¶
Package fsext provides extended file system functions
Index ¶
- Constants
- Variables
- func Abs(root, path string) string
- func Exists(fs Fs, path string) (bool, error)
- func IsDir(fs Fs, path string) (bool, error)
- func JoinFilePath(b, p string) string
- func NewCacheOnReadFs(base, layer afero.Fs, cacheTime time.Duration) afero.Fs
- func ReadDir(fs Fs, dirname string) ([]fs.FileInfo, error)
- func ReadFile(fs Fs, filename string) ([]byte, error)
- func Walk(fs afero.Fs, root string, walkFn filepath.WalkFunc) error
- func WriteFile(fs Fs, filename string, data []byte, perm fs.FileMode) error
- type CacheLayerGetter
- type CacheOnReadFs
- type ChangePathFile
- type ChangePathFs
- func (b *ChangePathFs) Chmod(name string, mode fs.FileMode) (err error)
- func (b *ChangePathFs) Chown(_ string, _, _ int) error
- func (b *ChangePathFs) Chtimes(name string, atime, mtime time.Time) (err error)
- func (b *ChangePathFs) Create(name string) (f afero.File, err error)
- func (b *ChangePathFs) LstatIfPossible(name string) (fs.FileInfo, bool, error)
- func (b *ChangePathFs) Mkdir(name string, mode fs.FileMode) (err error)
- func (b *ChangePathFs) MkdirAll(name string, mode fs.FileMode) (err error)
- func (b *ChangePathFs) Name() string
- func (b *ChangePathFs) Open(name string) (f afero.File, err error)
- func (b *ChangePathFs) OpenFile(name string, flag int, mode fs.FileMode) (f afero.File, err error)
- func (b *ChangePathFs) Remove(name string) (err error)
- func (b *ChangePathFs) RemoveAll(name string) (err error)
- func (b *ChangePathFs) Rename(oldName, newName string) (err error)
- func (b *ChangePathFs) Stat(name string) (fi fs.FileInfo, err error)
- type ChangePathFunc
- type Fs
- type OnlyCachedEnabler
Constants ¶
const FilePathSeparator = afero.FilePathSeparator
FilePathSeparator is the FilePathSeparator to be used within a file system
Variables ¶
var ErrPathNeverRequestedBefore = errors.New("path never requested before")
ErrPathNeverRequestedBefore represent an error when path never opened/requested before
Functions ¶
func Abs ¶ added in v0.48.0
Abs returns an absolute representation of path.
this implementation allows k6 to handle absolute paths starting from the current drive on windows like `\users\noname\...`. It makes it easier to test and is needed for archive execution under windows (it always consider '/...' as an absolute path).
If the path is not absolute it will be joined with root to turn it into an absolute path. The root path is assumed to be a directory.
Because k6 does not interact with the OS itself, but with its own virtual file system, it needs to be able to resolve the root path of the file system. In most cases this would be the bundle or init environment's working directory.
func JoinFilePath ¶ added in v0.44.0
JoinFilePath is a wrapper around filepath.Join starting go 1.20 on Windows, Clean (that is using inside the filepath.Join) does not modify the volume name other than to replace occurrences of "/" with `\`. that's why we need to add a leading slash to the path go.1.19: filepath.Join("\\c:", "test") // \c:\test go.1.20: filepath.Join("\\c:", "test") // \c:test
func NewCacheOnReadFs ¶
NewCacheOnReadFs returns a new CacheOnReadFs
Types ¶
type CacheLayerGetter ¶ added in v0.36.0
CacheLayerGetter provide a direct access to a cache layer
type CacheOnReadFs ¶
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
type ChangePathFile ¶
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 fs.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(_ string, _, _ 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 ¶
LstatIfPossible implements the afero.Lstater interface
func (*ChangePathFs) Mkdir ¶
func (b *ChangePathFs) Mkdir(name string, mode fs.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 fs.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) 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.
type ChangePathFunc ¶
ChangePathFunc is the function that will be called by ChangePathFs to change the path
type Fs ¶ added in v0.45.0
Fs represents a file system
func NewMemMapFs ¶ added in v0.45.0
func NewMemMapFs() Fs
NewMemMapFs returns a Fs that is in memory
func NewReadOnlyFs ¶ added in v0.45.0
NewReadOnlyFs returns a Fs wrapping the provided one and returning error on any not read operation.
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)