1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*!
# fdf - A High-Performance Parallel File System Traversal Library
`fdf` is a Rust library designed for efficient, parallel directory traversal
with extensive filtering capabilities. It leverages Rayon for parallel processing
and uses platform-specific optimisations for maximum performance.
**This will be renamed before a 1.0!**
## Features
- **Parallel Processing**: Utilises a custom work-stealing scheduler for concurrent
directory traversal
- **Platform Optimisations**: Linux/Android specific `getdents` system calls for optimal
performance, with fallbacks for other platforms
- **Flexible Filtering**: Support for multiple filtering criteria:
- File name patterns (regex,glob)
- File size ranges
- File types (regular, directory, symlink, etc.)
- File extensions
- Hidden file handling
- Custom filter functions
- **Cycle Detection**: Automatic symlink cycle prevention using inode caching
- **Depth Control**: Configurable maximum search depth
- **Path Canonicalisation**: Optional path resolution to absolute paths
- **Error Handling**: Configurable error reporting with detailed diagnostics
## Performance Characteristics
- Uses mimalloc as global allocator on supported platforms for improved (disabled with --no-default-features)
memory allocation performance
- Batched result delivery to minimise channel contention
- Zero-copy path handling where possible
- Avoids unnecessary `stat` calls through careful API design
## Platform Support
- **Linux/Android**: Optimised with direct `getdents64` system calls
- **macOS**: Support for `__getdirentries64` (to be allowed to be disabled in a future update)
- **Other Unix-like**: Fallback to standard library functions
- **Windows**: Not currently supported (PRs welcome!)
## Quick Start
```rust
use fdf::{walk::Finder, fs::DirEntry, SearchConfigError};
use std::sync::mpsc::Receiver;
fn find_files() -> Result<impl Iterator<Item = DirEntry>, SearchConfigError> {
let finder = Finder::init("/path/to/search")
.pattern("*.rs")
.keep_hidden(false)
.max_depth(Some(3))
.follow_symlinks(true)
.canonicalise_root(true) // Resolve the root to a full path
.build()?;
finder.traverse()
}
```
Setting custom filters example
```no_run
use fdf::{walk::Finder, filters::FileTypeFilter};
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let finder = Finder::init("/var/log")
.pattern("*.log")
.keep_hidden(false)
.type_filter(Some(FileTypeFilter::File))
//set the custom filter
.filter(Some(|entry| {
entry.extension().is_some_and( |ext| ext.eq_ignore_ascii_case(b"log"))
}))
.build()?;
let entries = finder.traverse()?;
let mut count = 0;
for entry in entries {
count += 1;
println!("Matched: {}", entry.as_path().display());
}
println!("Found {count} log files");
Ok(())
}
```
*/
compile_error!;
// Re-exports
pub use chrono;
pub use libc;
pub
pub use ;
pub use ;
pub use c_char;
pub use crateUnique;
pub use ;
pub use SearchConfig;