Every file under `root` with its length and modification time.
(root: &Path)
| 1305 | |
| 1306 | /// Every file under `root` with its length and modification time. |
| 1307 | fn snapshot(root: &Path) -> Vec<(String, u64, std::time::SystemTime)> { |
| 1308 | let mut entries = Vec::new(); |
| 1309 | let mut stack = vec![root.to_path_buf()]; |
| 1310 | while let Some(dir) = stack.pop() { |
| 1311 | for entry in std::fs::read_dir(&dir).unwrap().flatten() { |
| 1312 | let meta = entry.metadata().unwrap(); |
| 1313 | if meta.is_dir() { |
| 1314 | stack.push(entry.path()); |
| 1315 | } else { |
| 1316 | entries.push(( |
| 1317 | entry.path().display().to_string(), |
| 1318 | meta.len(), |
| 1319 | meta.modified().unwrap(), |
| 1320 | )); |
| 1321 | } |
| 1322 | } |
| 1323 | } |
| 1324 | entries.sort(); |
| 1325 | entries |
| 1326 | } |