Debian Codegraph @

README.md

raw symbols SCIP
1 # Opportunistic dirty file tracker
2
3 This library provides a simple way to track dirty files in a directory.
4 It uses the `notify` crate to watch for file system events and keep track
5 of the files that have been modified.
6
7 If the underlying file system does not support watching for file system events,
8 or if there are too many files to watch, the tracker will simply give up and
9 return `State::Unknown`.
10
11 Example:
12
13 ```rust
14 use dirty_tracker::{State, DirtyTracker};
15
16 let td = tempfile::tempdir().unwrap();
17
18 let mut tracker = DirtyTracker::new(td.path()).unwrap();
19 assert_eq!(tracker.state(), State::Clean);
20 assert!(tracker.paths().unwrap().is_empty());
21
22 // Modify a file in the directory.
23 std::fs::write(td.path().join("file"), b"hello").unwrap();
24
25 assert_eq!(tracker.state(), State::Dirty);
26 assert_eq!(tracker.paths(), Some(&maplit::hashset![td.path().join("file")]));
27 ```