Documentation
¶
Overview ¶
Package filter provides file and directory filtering capabilities for the doppel duplicate file finder.
This package implements filtering logic to exclude files and directories based on:
- Glob patterns for file and directory names
- Regular expressions for file and directory paths
- File size constraints (minimum and maximum sizes)
- Predefined filter presets for common use cases
The package supports parsing human-readable file sizes (e.g., "10MB", "1.5GB") and provides utilities to display active filter configurations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisplayActiveFilters ¶
func DisplayActiveFilters(config *Config)
DisplayActiveFilters prints the currently active file and directory filters from the provided configuration.
func ParseFileSize ¶
ParseFileSize parses a file size string with optional suffix and returns size in bytes. Supported formats:
- Plain numbers: "1024", "500" (treated as bytes)
- With suffixes: "10MB", "5.5GB", "1.5KiB", "2TB"
- Case insensitive: "10mb", "5GB", "1kib"
- Spaces allowed: "10 MB", "5.5 GB"
Note:
- Negatives are treated as 0.
Returns the size in bytes as int64, or error if parsing fails.
Types ¶
type Config ¶
type Config struct {
// ExcludeDirs contains directory names to exclude.
ExcludeDirs []string `json:"exclude_dirs" yaml:"exclude_dirs"`
// ExcludeFiles contains file names to exclude.
ExcludeFiles []string `json:"exclude_files" yaml:"exclude_files"`
// ExcludeDirRegexRaw contains the raw regex patterns for directories to exclude.
ExcludeDirRegexRaw []string `json:"exclude_dir_regex" yaml:"exclude_dir_regex"`
// ExcludeFileRegexRaw contains the raw regex patterns for files to exclude.
ExcludeFileRegexRaw []string `json:"exclude_file_regex" yaml:"exclude_file_regex"`
// MinSize is the minimum file size to include (0 means no minimum).
MinSize int64 `json:"min_size" yaml:"min_size"`
// MaxSize is the maximum file size to include (0 means no maximum).
MaxSize int64 `json:"max_size" yaml:"max_size"`
// contains filtered or unexported fields
}
Config defines criteria for excluding files and directories.
func BuildConfig ¶
func BuildConfig(excludeDirs, excludeFiles, excludeDirRegex, excludeFileRegex string, minSize, maxSize int64) (*Config, error)
BuildConfig creates a Config from command line arguments.
func GetPresetConfig ¶
GetPresetConfig returns a predefined Config based on the preset name
func (*Config) ShouldExcludeDir ¶
ShouldExcludeDir checks if a directory should be excluded based on filters.