Documentation
¶
Overview ¶
Package filesystem provides a filesystem-based scan source.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilesystemSource ¶
type FilesystemSource struct {
// contains filtered or unexported fields
}
FilesystemSource is a filesystem-based scan source. It scans one or more roots, each of which may be a directory (walked recursively) or a single file (scanned on its own).
func New ¶
func New(root string, opts ...Option) *FilesystemSource
New creates a new FilesystemSource for a single root. The root path is cleaned and resolved to an absolute path. The root may be a directory or a single file.
func NewMulti ¶ added in v1.7.0
func NewMulti(roots []string, opts ...Option) *FilesystemSource
NewMulti creates a FilesystemSource that scans several roots in one pass. Each root is cleaned and resolved to an absolute path and may be a directory (walked recursively) or a single file. A file reachable from more than one root is scanned only once.
func (*FilesystemSource) Chunks ¶
func (s *FilesystemSource) Chunks(ctx context.Context) <-chan source.Chunk
Chunks walks every configured root and sends chunks over a channel.
func (*FilesystemSource) Err ¶ added in v1.7.0
func (s *FilesystemSource) Err() error
Err returns the first terminal error that aborted the filesystem walk, or nil if it completed normally. It must only be called after the channel returned by Chunks has been fully drained (closed).
func (*FilesystemSource) Type ¶
func (s *FilesystemSource) Type() string
Type returns the source type.
func (*FilesystemSource) Validate ¶
func (s *FilesystemSource) Validate() error
Validate checks that every scan root exists and is accessible. A root may be either a directory or a regular file; only inaccessibility (e.g. a non-existent path or a permission error) is rejected.
type Option ¶
type Option func(*FilesystemSource)
Option configures a FilesystemSource.
func WithBufferSize ¶
WithBufferSize sets the chunk channel buffer size.
func WithExcludeExtensions ¶
WithExcludeExtensions sets file extensions to exclude from scanning.
func WithExcludePaths ¶
WithExcludePaths sets path patterns to exclude from scanning.
func WithMaxFileSize ¶
WithMaxFileSize sets the maximum file size to scan.