fileutils

package
v1.56.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 70

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) (int64, error)

CopyFile copies from src to dst until either EOF is reached on src or an error occurs. It verifies src exists and removes the dst if it exists.

func CreateIfNotExists

func CreateIfNotExists(path string, isDir bool) error

CreateIfNotExists creates a file or a directory only if it does not already exist.

func Exists added in v1.54.0

func Exists(path string) error

Exists checks whether a file or directory exists at the given path. If the path is a symlink, the symlink is followed.

func GetTotalUsedFds

func GetTotalUsedFds() int

GetTotalUsedFds Returns the number of used File Descriptors by reading it via /proc filesystem.

func Lexists added in v1.54.0

func Lexists(path string) error

Lexists checks whether a file or directory exists at the given path. If the path is a symlink, the symlink itself is checked.

func Matches

func Matches(file string, patterns []string) (bool, error)

Matches returns true if file matches any of the patterns and isn't excluded by any of the subsequent patterns.

func ReadSymlinkedDirectory

func ReadSymlinkedDirectory(path string) (string, error)

ReadSymlinkedDirectory returns the target directory of a symlink. The target of the symbolic link may not be a file.

func ReadSymlinkedPath

func ReadSymlinkedPath(path string) (realPath string, err error)

ReadSymlinkedPath returns the target directory of a symlink. The target of the symbolic link can be a file and a directory.

Types

type MatchResult

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

func (*MatchResult) Excludes

func (m *MatchResult) Excludes() uint

Excludes returns the amount of excludes of an MatchResult

func (*MatchResult) IsMatched

func (m *MatchResult) IsMatched() bool

Excludes returns true if the overall result is matched

func (*MatchResult) Matches

func (m *MatchResult) Matches() uint

Excludes returns the amount of matches of an MatchResult

type Pattern

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

Pattern defines a single regexp used to filter file paths.

func (*Pattern) Exclusion

func (p *Pattern) Exclusion() bool

Exclusion returns true if this pattern defines exclusion

func (*Pattern) String

func (p *Pattern) String() string

type PatternMatcher

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

PatternMatcher allows checking paths against a list of patterns

func NewPatternMatcher

func NewPatternMatcher(patterns []string) (*PatternMatcher, error)

NewPatternMatcher creates a new matcher object for specific patterns that can be used later to match against patterns against paths

func (*PatternMatcher) Exclusions

func (pm *PatternMatcher) Exclusions() bool

Exclusions returns true if any of the patterns define exclusions

func (*PatternMatcher) IsMatch

func (pm *PatternMatcher) IsMatch(file string) (matched bool, err error)

IsMatch verifies the provided filepath against all patterns and returns true if it matches. A match is valid if the last match is a positive one. It returns an error on failure and is not safe to be called concurrently.

func (*PatternMatcher) Matches deprecated

func (pm *PatternMatcher) Matches(file string) (bool, error)

Deprecated: Please use the `MatchesResult` method instead. Matches matches path against all the patterns. Matches is not safe to be called concurrently

func (*PatternMatcher) MatchesResult

func (pm *PatternMatcher) MatchesResult(file string) (res *MatchResult, err error)

MatchesResult verifies the provided filepath against all patterns. It returns the `*MatchResult` result for the patterns on success, otherwise an error. This method is not safe to be called concurrently.

func (*PatternMatcher) Patterns

func (pm *PatternMatcher) Patterns() []*Pattern

Patterns returns array of active patterns

Jump to

Keyboard shortcuts

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