internal

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSymlinkInfoExpected = errors.New("expecting a symlink file-info")
	ErrDirInfoExpected     = errors.New("expecting a directory file-info")
	ErrFileInfoExpected    = errors.New("expecting a file file-info")

	// internal package does not expose these errors
	ErrCopyFileFailed = errors.New("failed to copy file")

	ErrCopyDirFailed = errors.New("failed to copy directory")
)

reference: os package

View Source
var ErrNoLchown = errors.New("lchown not supported")

ErrNoLchown is the error that will be wrapped in an os.Path if a file system does not support the lchown operation either directly or through its delegated filesystem. As expressed by support for the LinkOwner interface.

Functions

func AllFiles added in v0.7.1

func AllFiles(fs afero.Fs, dir string) ([]string, error)

func Chmod added in v0.5.0

func Chmod(t *testing.T, fs afero.Fs, path string, perm os.FileMode)

func Chown added in v0.2.0

func Chown(from os.FileInfo, toName string, fs afero.Fs) error

Chown is an operating system dependent implementation. only tries to change owner in cas ethat the owner differs

func CopyDir

func CopyDir(fs afero.Fs, name string, info os.FileInfo) error

func CopyFile

func CopyFile(fs afero.Fs, name string, info os.FileInfo, sourceFile afero.File) error
func CopySymlink(source, target afero.Fs, name string, info os.FileInfo, errBaseFsNoSymlink, errBackupFsNoSymlink error) error

func CountFiles added in v0.7.1

func CountFiles(t *testing.T, fs afero.Fs, path string, expectedFilesAndDirs int)

func CreateFile

func CreateFile(t *testing.T, fs afero.Fs, path, content string)

func CreateMemDir

func CreateMemDir(path string, perm os.FileMode) os.FileInfo

func CreateMemFile

func CreateMemFile(path, content string, perm os.FileMode) afero.File
func CreateSymlink(t *testing.T, fs afero.Fs, oldpath, newpath string)

func DirContains added in v0.7.1

func DirContains(parent, subdir string) (bool, error)

func EqualMode added in v0.5.1

func EqualMode(a, b os.FileMode) bool

EqualMode is os-Dependent

func EqualOwner added in v0.6.0

func EqualOwner(a os.FileInfo, uid, gid int) bool

func Exists

func Exists(fs afero.Fs, path string) (bool, error)

Check if a file or directory exists.

func FileMustContainText

func FileMustContainText(t *testing.T, fs afero.Fs, path, content string)

func Gid added in v0.2.0

func Gid(from os.FileInfo) int

func IgnorableChownError added in v0.7.4

func IgnorableChownError(err error) error

IgnorableChownError is solely used in Chown

func IgnorableChtimesError added in v0.7.4

func IgnorableChtimesError(err error) error

IgnorableChtimesError is solely used for Chtimes

func IsHidden added in v0.7.1

func IsHidden(name string, hiddenPaths []string) (bool, error)

func IsInHiddenPath added in v0.7.1

func IsInHiddenPath(name, hiddenDir string) (relPath string, inHiddenPath bool, err error)

func IsParentOfHiddenDir added in v0.7.1

func IsParentOfHiddenDir(name string, hiddenPaths []string) (bool, error)

func IterateDirTree added in v0.2.0

func IterateDirTree(name string, visitor func(string) error) error

func LExists added in v0.4.0

func LExists(fs afero.Fs, path string) (bool, error)

Check if a symlin, file or directory exists.

func LchownIfPossible added in v0.6.1

func LchownIfPossible(fs afero.Fs, name string, uid, gid int) error

tries lchown, does not guarantee success

func LstatIfPossible added in v0.5.0

func LstatIfPossible(fs afero.Fs, path string) (os.FileInfo, bool, error)

LstatIfPossible uses Lstat or stat in case it is possible. returns the fileinfo of the symlink or of the linked file or of the file in case there is no symlink. The second return value returns true in case Lstat was actually called, false otherwise.

func LstaterIfPossible added in v0.4.0

func LstaterIfPossible(fs afero.Fs) (afero.Lstater, bool)

Check if interface is implemented

func Mkdir added in v0.5.0

func Mkdir(t *testing.T, fs afero.Fs, path string, perm os.FileMode) error

func MkdirAll added in v0.2.0

func MkdirAll(t *testing.T, fs afero.Fs, path string, perm os.FileMode)

func ModeMustBeEqual added in v0.5.0

func ModeMustBeEqual(t *testing.T, a, b os.FileMode)

func MustExist

func MustExist(t *testing.T, fs afero.Fs, path string)

func MustLExist added in v0.4.0

func MustLExist(t *testing.T, fs afero.Fs, path string)

func MustNotExist

func MustNotExist(t *testing.T, fs afero.Fs, path string)

func MustNotLExist added in v0.4.0

func MustNotLExist(t *testing.T, fs afero.Fs, path string)

func OpenFile

func OpenFile(t *testing.T, fs afero.Fs, path, content string, perm os.FileMode)

func RemoveAll added in v0.2.0

func RemoveAll(t *testing.T, fs afero.Fs, path string)

func RemoveFile

func RemoveFile(t *testing.T, fs afero.Fs, path string)

func RestoreFile added in v0.2.0

func RestoreFile(name string, backupFi os.FileInfo, base, backup afero.Fs) error
func RestoreSymlink(name string, backupFi os.FileInfo, base, backup afero.Fs, errBaseFsNoSymlink, errBackupFsNoSymlink error) error

func SymlinkMustExist added in v0.4.0

func SymlinkMustExist(t *testing.T, fs afero.Fs, symlinkPath string)

func SymlinkMustExistWithTragetPath added in v0.4.0

func SymlinkMustExistWithTragetPath(t *testing.T, fs afero.Fs, symlinkPath, expectedPointsTo string)

func Uid added in v0.2.0

func Uid(from os.FileInfo) int

Types

type ByLeastFilePathSeparators added in v0.2.0

type ByLeastFilePathSeparators []string

ByLeastFilePathSeparators sorts the string by the number of file path separators the least nested the file path is, the further at the beginning it will be of the sorted string slice.

func (ByLeastFilePathSeparators) Len added in v0.2.0

func (ByLeastFilePathSeparators) Less added in v0.2.0

func (a ByLeastFilePathSeparators) Less(i, j int) bool

func (ByLeastFilePathSeparators) Swap added in v0.2.0

func (a ByLeastFilePathSeparators) Swap(i, j int)

type ByMostFilePathSeparators added in v0.2.0

type ByMostFilePathSeparators []string

ByMostFilePathSeparators sorts the string by the number of file path separators the more nested this is, the further at the beginning of the string slice the path will be

func (ByMostFilePathSeparators) Len added in v0.2.0

func (a ByMostFilePathSeparators) Len() int

func (ByMostFilePathSeparators) Less added in v0.2.0

func (a ByMostFilePathSeparators) Less(i, j int) bool

func (ByMostFilePathSeparators) Swap added in v0.2.0

func (a ByMostFilePathSeparators) Swap(i, j int)

type LinkOwner added in v0.6.1

type LinkOwner interface {
	LchownIfPossible(name string, uid int, gid int) error
}

LinkOwner is an optional interface in Afero. It is only implemented by the filesystems saying so.

type SymlinkFs added in v0.4.0

type SymlinkFs interface {
	afero.Fs
	afero.Symlinker
}

type SymlinkerFs added in v0.4.0

type SymlinkerFs interface {
	afero.Fs
	afero.Symlinker
	LinkOwner
}

Jump to

Keyboard shortcuts

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