Design Task: Object-Oriented module that mimics UNIX find
Context
Design an object-oriented library that replicates the core functionality of the UNIX find command for searching a filesystem by various criteria. The module should be usable as a library and also expose a command-style fluent API for easy composition.
Functional Requirements
-
Filters
-
Name pattern: glob and regex
-
File type: file, directory, symlink
-
Size ranges: e.g., >10 MB, between 1–5 KB
-
Times: modification time (mtime), creation/birth time (if available), change time (ctime)
-
Permissions/owner/group
-
Depth limits: maxDepth, minDepth
-
Predicate composition: AND, OR, NOT
-
Symlink handling: options to follow or skip symlinks; prevent cycles
-
Outputs: emit path strings and/or structured file metadata
Non-Functional Requirements
-
Traversal and performance
-
Early pruning of subtrees when possible (depth/type/name pre-checks)
-
Optional concurrency: parallel directory traversal with backpressure
-
Efficient directory iteration and stat calls
-
Robustness
-
Handle very large directories and deep trees without recursion overflow
-
Graceful handling of permission errors, races (file disappears), broken symlinks
-
Cancellation and timeouts
Deliverables
-
Proposed APIs
-
Command-style fluent builder
-
Library-style iterator/stream API
-
Extensibility: how to add new filters/predicates
-
Traversal algorithm and performance considerations
-
Robustness/error-handling strategy
-
Class diagrams or interfaces and key data structures
-
Representative test cases