generated from snivilised/astrolib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2e7990
commit de86747
Showing
62 changed files
with
3,591 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,119 @@ | ||
package core | ||
|
||
type FilterDef struct { | ||
import ( | ||
"io/fs" | ||
|
||
"github.com/snivilised/traverse/enums" | ||
) | ||
|
||
// TraverseFilter filter that can be applied to file system entries. When specified, | ||
// the callback will only be invoked for file system nodes that pass the filter. | ||
type ( | ||
TraverseFilter interface { | ||
// Description describes filter | ||
Description() string | ||
|
||
// Validate ensures the filter definition is valid, panics when invalid | ||
Validate() | ||
|
||
// Source, filter definition (comes from filter definition Pattern) | ||
Source() string | ||
|
||
// IsMatch does this item match the filter | ||
IsMatch(item *Node) bool | ||
|
||
// IsApplicable is this filter applicable to this item's scope | ||
IsApplicable(item *Node) bool | ||
|
||
// Scope, what items this filter applies to | ||
Scope() enums.FilterScope | ||
} | ||
|
||
FilterDef struct { | ||
// Type specifies the type of filter (mandatory) | ||
Type enums.FilterType | ||
|
||
// Description describes filter (optional) | ||
Description string | ||
|
||
// Pattern filter definition (mandatory) | ||
Pattern string | ||
|
||
// Scope which file system entries this filter applies to (defaults | ||
// to ScopeAllEn) | ||
Scope enums.FilterScope | ||
|
||
// Negate, reverses the applicability of the filter (Defaults to false) | ||
Negate bool | ||
|
||
// IfNotApplicable, when the filter does not apply to a directory entry, | ||
// this value determines whether the callback is invoked for this entry | ||
// or not (defaults to true). | ||
IfNotApplicable enums.TriStateBool | ||
|
||
// Custom client define-able filter. When restoring for resume feature, | ||
// its the client's responsibility to restore this themselves (see | ||
// PersistenceRestorer) | ||
Custom TraverseFilter `json:"-"` | ||
|
||
// Poly allows for the definition of a PolyFilter which contains separate | ||
// filters that target files and folders separately. If present, then | ||
// all other fields are redundant, since the filter definitions inside | ||
// Poly should be referred to instead. | ||
Poly *PolyFilterDef | ||
} | ||
|
||
PolyFilterDef struct { | ||
File FilterDef | ||
Folder FilterDef | ||
} | ||
|
||
// ChildTraverseFilter filter that can be applied to a folder's collection of entries | ||
// when subscription is | ||
|
||
ChildTraverseFilter interface { | ||
// Description describes filter | ||
Description() string | ||
|
||
// Validate ensures the filter definition is valid, panics when invalid | ||
Validate() | ||
|
||
// Source, filter definition (comes from filter definition Pattern) | ||
Source() string | ||
|
||
// Matching returns the collection of files contained within this | ||
// item's folder that matches this filter. | ||
Matching(children []fs.DirEntry) []fs.DirEntry | ||
} | ||
|
||
ChildFilterDef struct { | ||
// Type specifies the type of filter (mandatory) | ||
Type enums.FilterType | ||
|
||
// Description describes filter (optional) | ||
Description string | ||
|
||
// Pattern filter definition (mandatory) | ||
Pattern string | ||
|
||
// Negate, reverses the applicability of the filter (Defaults to false) | ||
Negate bool | ||
|
||
// Custom client define-able filter. When restoring for resume feature, | ||
// its the client's responsibility to restore this themselves (see | ||
// PersistenceRestorer) | ||
Custom ChildTraverseFilter `json:"-"` | ||
} | ||
|
||
compoundCounters struct { | ||
filteredIn uint | ||
filteredOut uint | ||
} | ||
) | ||
|
||
var BenignNodeFilterDef = FilterDef{ | ||
Type: enums.FilterTypeRegex, | ||
Description: "benign allow all", | ||
Pattern: ".", | ||
Scope: enums.ScopeRoot, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.