Documentation
¶
Index ¶
- Variables
- func IsBtrfs(path string) bool
- type DirEntry
- type FileInfo
- type FileSystem
- type LocalFS
- func (l *LocalFS) Chtimes(path string, atime, mtime time.Time) error
- func (l *LocalFS) Close() error
- func (l *LocalFS) IsReadableDirectory(path string) bool
- func (l *LocalFS) Lstat(path string) (FileInfo, error)
- func (l *LocalFS) MkdirAll(path string) error
- func (l *LocalFS) ReadAt(path string, buf []byte, offset int64) (int, error)
- func (l *LocalFS) ReadFile(path string) ([]byte, error)
- func (l *LocalFS) Rename(oldPath, newPath string) error
- func (l *LocalFS) Stat(path string) (FileInfo, error)
- func (l *LocalFS) Walk(dirPath string, excludedNames map[string]struct{}, counter *int32) ([]DirEntry, error)
- type SFTPFS
- func (s *SFTPFS) Chtimes(p string, atime, mtime time.Time) error
- func (s *SFTPFS) Close() error
- func (s *SFTPFS) IsReadableDirectory(p string) bool
- func (s *SFTPFS) Lstat(p string) (FileInfo, error)
- func (s *SFTPFS) MkdirAll(p string) error
- func (s *SFTPFS) ReadAt(p string, buf []byte, offset int64) (int, error)
- func (s *SFTPFS) ReadFile(p string) ([]byte, error)
- func (s *SFTPFS) Rename(oldPath, newPath string) error
- func (s *SFTPFS) Stat(p string) (FileInfo, error)
- func (s *SFTPFS) Walk(dirPath string, excludedNames map[string]struct{}, counter *int32) ([]DirEntry, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultArchiveOneFileSystem bool
DefaultArchiveOneFileSystem is the default for OneFileSystem on archive scans.
var DefaultOneFileSystem bool
DefaultOneFileSystem is the default for OneFileSystem on new LocalFS instances (src+dst scans).
var ErrNotBtrfs = fmt.Errorf("not a btrfs filesystem")
BtrfsWalk performs a recursive directory walk using BTRFS_IOC_TREE_SEARCH to batch-read directory entries and inode metadata. If a subdirectory is on a different device (submount), it falls back to standard stat-based walk for that subtree. Returns ErrNotBtrfs if the root path is not on BTRFS.
Functions ¶
Types ¶
type DirEntry ¶
type DirEntry struct {
// RelativePath is the path relative to the walk root.
RelativePath string
// Size is the file size in bytes (0 for directories).
Size int64
// ModTime is the modification time as a Unix timestamp.
ModTime int64
// IsDir is true for directory entries.
IsDir bool
}
DirEntry represents a single file or directory discovered during Walk.
type FileSystem ¶
type FileSystem interface {
// Walk recursively walks dirPath, returning all regular files.
// excludedNames contains base names to skip (files and directories).
// counter, if non-nil, is incremented atomically for each regular file found.
Walk(dirPath string, excludedNames map[string]struct{}, counter *int32) ([]DirEntry, error)
// Lstat returns file info without following symlinks.
Lstat(path string) (FileInfo, error)
// Stat returns file info, following symlinks.
Stat(path string) (FileInfo, error)
// ReadFile reads the entire file.
ReadFile(path string) ([]byte, error)
// ReadAt reads len(buf) bytes starting at offset.
ReadAt(path string, buf []byte, offset int64) (int, error)
// Rename moves/renames a file.
Rename(oldPath, newPath string) error
// Chtimes changes the access and modification times of the named file.
Chtimes(path string, atime, mtime time.Time) error
// MkdirAll creates a directory path and all parents that do not yet exist.
MkdirAll(path string) error
// IsReadableDirectory returns true if path is an existing, readable directory.
IsReadableDirectory(path string) bool
// Close releases any resources held by the filesystem (e.g. SSH connections).
Close() error
}
FileSystem abstracts file system operations so that callers can work with local directories, SFTP mounts, or remote agents interchangeably.
type LocalFS ¶
type LocalFS struct {
OneFileSystem bool // if true, skip directories on different filesystems
// contains filtered or unexported fields
}
LocalFS implements FileSystem using standard os.* calls.
func NewLocalFSForArchive ¶
func NewLocalFSForArchive() *LocalFS
NewLocalFSForArchive returns a LocalFS configured for archive scanning.