Documentation
¶
Overview ¶
Copyright 2025 AlaudaDevops authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package fscopy provides file manipulation utilities
Index ¶
- type FileCopier
- type FileFilter
- type FileSelector
- type FileSystemCopier
- func (s *FileSystemCopier) Copy(ctx context.Context, base, destination string, files ...ifs.FileInfo) error
- func (s *FileSystemCopier) CopyFile(ctx context.Context, base, destination string, file ifs.FileInfo) error
- func (s *FileSystemCopier) Link(ctx context.Context, base, destination string, links ...ifs.LinkRequest) error
- type FileSystemSelector
- type FileTreeOperator
- type IgnoreNode
- func (n *IgnoreNode) AddChild(path string, matcher goignore.IgnoreMatcher) bool
- func (n *IgnoreNode) IsFileAllowed(ctx context.Context, file ifs.FileInfo) (bool, error)
- func (n *IgnoreNode) ListMatchers(path string) (result map[string]goignore.IgnoreMatcher)
- func (n *IgnoreNode) WalkDirFunc(ctx context.Context, path string, d fs.DirEntry, err error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileCopier ¶
type FileCopier interface {
Copy(ctx context.Context, base, dst string, files ...ifs.FileInfo) error
Link(ctx context.Context, base, dst string, links ...ifs.LinkRequest) error
}
FileCopier copies files from a given path to a destination base is the original base path dst is the destination path files is the list of files to copy
type FileFilter ¶
FileFilter checks if a files is allowed to be copied
type FileSelector ¶
type FileSelector interface {
ListFiles(ctx context.Context, path string, filters ...FileFilter) ([]ifs.FileInfo, error)
}
FileSelector selects files from a given path respecting .syncignore files rules in the given path or in its subfolders returning a list of allowed files
type FileSystemCopier ¶
type FileSystemCopier struct {
}
func (*FileSystemCopier) Copy ¶
func (s *FileSystemCopier) Copy(ctx context.Context, base, destination string, files ...ifs.FileInfo) error
Copy copies a list of files using a base and destination folders implements the FileCopier interface
func (*FileSystemCopier) CopyFile ¶
func (s *FileSystemCopier) CopyFile(ctx context.Context, base, destination string, file ifs.FileInfo) error
CopyFile copies one file from base to destination
func (*FileSystemCopier) Link ¶
func (s *FileSystemCopier) Link(ctx context.Context, base, destination string, links ...ifs.LinkRequest) error
Link will create symlinks based on the base and destination folders given the list links it will ignore if the destination folder was already created and the link already exists
type FileSystemSelector ¶
type FileSystemSelector struct {
}
FileSystemSelector implements a file selector using the local file system
func (*FileSystemSelector) ListFiles ¶
func (s *FileSystemSelector) ListFiles(ctx context.Context, path string, filters ...FileFilter) ([]ifs.FileInfo, error)
ListFiles implements the FileSelector interface
type FileTreeOperator ¶
type FileTreeOperator interface {
WalkDirFunc(ctx context.Context, path string, d fs.DirEntry, err error) error
}
FileTreeOperator operator to walk a file tree and do its own processing
type IgnoreNode ¶
type IgnoreNode struct {
// contains filtered or unexported fields
}
IgnoreNode represents a node in a ignore file filter, and can be used directly to check if a given path is ignored
func (*IgnoreNode) AddChild ¶
func (n *IgnoreNode) AddChild(path string, matcher goignore.IgnoreMatcher) bool
AddChild tries to add the child to an existing child verifying if it should be added down the tree otherwise will add to its own children
func (*IgnoreNode) IsFileAllowed ¶
IsFileAllowed implements the FileFilter interface returning true if the file is allowed and false if it should be ignored
func (*IgnoreNode) ListMatchers ¶
func (n *IgnoreNode) ListMatchers(path string) (result map[string]goignore.IgnoreMatcher)
ListMatchers returns a map of matchers for the given path matching the path and all its ancestors
func (*IgnoreNode) WalkDirFunc ¶
WalkDirFunc implements the FileTreeOperator interface