package fsutil
import "github.com/tonistiigi/fsutil"
Index ¶
- func Changes(ctx context.Context, a, b walkerFn, changeFn ChangeFunc) error
- func ComparePath(p1, p2 string) int
- func FollowLinks(fs FS, paths []string) ([]string, error)
- func Receive(ctx context.Context, conn Stream, dest string, opt ReceiveOpt) error
- func Send(ctx context.Context, conn Stream, fs FS, progressCb func(int, bool)) error
- func Stat(path string) (*types.Stat, error)
- func Walk(ctx context.Context, p string, opt *FilterOpt, fn filepath.WalkFunc) error
- func WalkDir(ctx context.Context, p string, opt *FilterOpt, fn gofs.WalkDirFunc) error
- func WriteTar(ctx context.Context, fs FS, w io.Writer) error
- type ChangeFunc
- type ChangeKind
- type ContentHasher
- type DiffType
- type Dir
- type DirEntryInfo
- func (s *DirEntryInfo) Info() (gofs.FileInfo, error)
- func (s *DirEntryInfo) IsDir() bool
- func (s *DirEntryInfo) Name() string
- func (s *DirEntryInfo) Type() gofs.FileMode
- type DiskWriter
- func NewDiskWriter(ctx context.Context, dest string, opt DiskWriterOpt) (*DiskWriter, error)
- func (dw *DiskWriter) HandleChange(kind ChangeKind, p string, fi os.FileInfo, err error) (retErr error)
- func (dw *DiskWriter) Wait(ctx context.Context) error
- type DiskWriterOpt
- type FS
- func NewFS(root string) (FS, error)
- func NewFilterFS(fs FS, opt *FilterOpt) (FS, error)
- func SubDirFS(dirs []Dir) (FS, error)
- func WithHardlinkReset(fs FS) FS
- type FilterFunc
- type FilterOpt
- type HandleChangeFn
- type Hardlinks
- type MapFunc
- type MapResult
- type ReceiveOpt
- type StatInfo
- func (s *StatInfo) IsDir() bool
- func (s *StatInfo) ModTime() time.Time
- func (s *StatInfo) Mode() os.FileMode
- func (s *StatInfo) Name() string
- func (s *StatInfo) Size() int64
- func (s *StatInfo) Sys() interface{}
- type Stream
- type Validator
- type WriteToFunc
Functions ¶
func Changes ¶
func Changes(ctx context.Context, a, b walkerFn, changeFn ChangeFunc) error
func ComparePath ¶
func FollowLinks ¶
func Receive ¶
func Send ¶
func Stat ¶
func Walk ¶
func WalkDir ¶
func WriteTar ¶
Types ¶
type ChangeFunc ¶
ChangeFunc is the type of function called for each change computed during a directory changes calculation.
type ChangeKind ¶
type ChangeKind int
ChangeKind is the type of modification that a change is making.
const ( // ChangeKindAdd represents an addition of // a file ChangeKindAdd ChangeKind = iota // ChangeKindModify represents a change to // an existing file ChangeKindModify // ChangeKindDelete represents a delete of // a file ChangeKindDelete )
func (ChangeKind) String ¶
func (k ChangeKind) String() string
type ContentHasher ¶
type DiffType ¶
type DiffType int
type Dir ¶
type DirEntryInfo ¶
func (*DirEntryInfo) Info ¶
func (s *DirEntryInfo) Info() (gofs.FileInfo, error)
func (*DirEntryInfo) IsDir ¶
func (s *DirEntryInfo) IsDir() bool
func (*DirEntryInfo) Name ¶
func (s *DirEntryInfo) Name() string
func (*DirEntryInfo) Type ¶
func (s *DirEntryInfo) Type() gofs.FileMode
type DiskWriter ¶
type DiskWriter struct {
// contains filtered or unexported fields
}
func NewDiskWriter ¶
func NewDiskWriter(ctx context.Context, dest string, opt DiskWriterOpt) (*DiskWriter, error)
func (*DiskWriter) HandleChange ¶
func (dw *DiskWriter) HandleChange(kind ChangeKind, p string, fi os.FileInfo, err error) (retErr error)
func (*DiskWriter) Wait ¶
func (dw *DiskWriter) Wait(ctx context.Context) error
type DiskWriterOpt ¶
type DiskWriterOpt struct {
AsyncDataCb WriteToFunc
SyncDataCb WriteToFunc
NotifyCb func(ChangeKind, string, os.FileInfo, error) error
ContentHasher ContentHasher
Filter FilterFunc
}
type FS ¶
type FS interface {
Walk(context.Context, string, gofs.WalkDirFunc) error
Open(string) (io.ReadCloser, error)
}
func NewFS ¶
NewFS creates a new FS from a root directory on the host filesystem.
func NewFilterFS ¶
NewFilterFS creates a new FS that filters the given FS using the given FilterOpt.
The returned FS will not contain any paths that do not match the provided include and exclude patterns, or that are are excluded using the mapping function.
The FS is assumed to be a snapshot of the filesystem at the time of the call to NewFilterFS. If the underlying filesystem changes, calls to the underlying FS may be inconsistent.
func SubDirFS ¶
func WithHardlinkReset ¶
WithHardlinkReset returns a FS that fixes hardlinks for FS that has been filtered so that original hardlink sources might be missing
type FilterFunc ¶
type FilterOpt ¶
type FilterOpt struct {
// IncludePatterns requires that the path matches at least one of the
// specified patterns.
IncludePatterns []string
// ExcludePatterns requires that the path does not match any of the
// specified patterns.
ExcludePatterns []string
// FollowPaths contains symlinks that are resolved into IncludePatterns
// at the time of the call to NewFilterFS.
FollowPaths []string
// Map is called for each path that is included in the result.
// The function can modify the stat info for each element, while the result
// of the function controls both how Walk continues.
Map MapFunc
}
type HandleChangeFn ¶
type Hardlinks ¶
type Hardlinks struct {
// contains filtered or unexported fields
}
func (*Hardlinks) HandleChange ¶
type MapFunc ¶
type MapResult ¶
type MapResult int
The result of the walk function controls both how WalkDir continues and whether the path is kept.
const ( // Keep the current path and continue. MapResultKeep MapResult = iota // Exclude the current path and continue. MapResultExclude // Exclude the current path, and skip the rest of the dir. // If path is a dir, skip the current directory. // If path is a file, skip the rest of the parent directory. // (This matches the semantics of fs.SkipDir.) MapResultSkipDir )
type ReceiveOpt ¶
type ReceiveOpt struct {
NotifyHashed ChangeFunc
ContentHasher ContentHasher
ProgressCb func(int, bool)
Merge bool
Filter FilterFunc
Differ DiffType
MetadataOnly FilterFunc
}
type StatInfo ¶
func (*StatInfo) IsDir ¶
func (*StatInfo) ModTime ¶
func (*StatInfo) Mode ¶
func (*StatInfo) Name ¶
func (*StatInfo) Size ¶
func (*StatInfo) Sys ¶
func (s *StatInfo) Sys() interface{}
type Stream ¶
type Stream interface {
RecvMsg(interface{}) error
SendMsg(m interface{}) error
Context() context.Context
}
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func (*Validator) HandleChange ¶
func (v *Validator) HandleChange(kind ChangeKind, p string, fi os.FileInfo, err error) (retErr error)
type WriteToFunc ¶
Source Files ¶
buffer.go chtimes_nolinux.go diff.go diff_containerd.go diskwriter.go diskwriter_windows.go filter.go followlinks.go followlinks_windows.go fs.go hardlinks.go receive.go send.go stat.go stat_windows.go tarwriter.go validator.go
Directories ¶
| Path | Synopsis |
|---|---|
| cmd | |
| cmd/receive | |
| cmd/send | |
| cmd/walk | |
| copy | |
| types | |
| util |
- Version
- v0.0.0-20250417144416-3f76f8130144 (latest)
- Published
- Apr 17, 2025
- Platform
- windows/amd64
- Imports
- 25 packages
- Last checked
- 11 months ago –
Tools for package owners.