fs

package
v0.0.0-...-bec5f0e Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 19 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowWildcards

func AllowWildcards(ci *CopyInfo)

func AllowXAttrErrors

func AllowXAttrErrors(ci *CopyInfo)

func Chown

func Chown(p string, old *User, fn Chowner) error

func Copy

func Copy(ctx context.Context, srcRoot, src, dstRoot, dst string, opts ...Opt) error

Copy copies files using `cp -a` semantics. Copy is likely unsafe to be used in non-containerized environments.

func GetLinkInfo

func GetLinkInfo(fi os.FileInfo) (uint64, bool)

GetLinkInfo returns an identifier representing the node a hardlink is pointing to. If the file is not hard linked then 0 will be returned.

func MkdirAll

func MkdirAll(path string, perm os.FileMode, user Chowner, tm *time.Time) ([]string, error)

MkdirAll is forked os.MkdirAll

func ResolveWildcards

func ResolveWildcards(root, src string, followLinks bool) ([]string, error)

func StatAtime

func StatAtime(st *syscall.Stat_t) syscall.Timespec

Returns the last-accessed time

func StatMtime

func StatMtime(st *syscall.Stat_t) syscall.Timespec

Returns the last-modified time

func Utimes

func Utimes(p string, tm *time.Time) error

func WithCopyInfo

func WithCopyInfo(ci CopyInfo) func(*CopyInfo)

Types

type Chowner

type Chowner func(*User) (*User, error)

type CopyInfo

type CopyInfo struct {
	Chown          Chowner
	Utime          *time.Time
	AllowWildcards bool
	Mode           *int
	// ModeStr is mode in non-octal format. Overrides Mode if non-empty.
	ModeStr           string
	XAttrErrorHandler XAttrErrorHandler
	CopyDirContents   bool
	FollowLinks       bool
	// Include only files/dirs matching at least one of these patterns
	IncludePatterns []string
	// Exclude files/dir matching any of these patterns (even if they match an include pattern)
	ExcludePatterns []string
	// If true, any source path that overwrite existing destination paths will always replace
	// the existing destination path, even if they are of different types (e.g. a directory will
	// replace any existing symlink or file)
	AlwaysReplaceExistingDestPaths bool
	ChangeFunc                     fsutil.ChangeFunc
}

type Opt

type Opt func(*CopyInfo)

func WithChangeNotifier

func WithChangeNotifier(fn fsutil.ChangeFunc) Opt

func WithChown

func WithChown(uid, gid int) Opt

func WithExcludePattern

func WithExcludePattern(excludePattern string) Opt

func WithIncludePattern

func WithIncludePattern(includePattern string) Opt

func WithXAttrErrorHandler

func WithXAttrErrorHandler(h XAttrErrorHandler) Opt

type User

type User struct {
	UID, GID int
	SID      string
}

type XAttrErrorHandler

type XAttrErrorHandler func(dst, src, xattrKey string, err error) error

Jump to

Keyboard shortcuts

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