| 358 | |
| 359 | fn persistent_files(root: &std::path::Path) -> std::collections::BTreeMap<String, Vec<u8>> { |
| 360 | fn collect( |
| 361 | root: &std::path::Path, |
| 362 | dir: &std::path::Path, |
| 363 | out: &mut std::collections::BTreeMap<String, Vec<u8>>, |
| 364 | ) { |
| 365 | for entry in std::fs::read_dir(dir).unwrap() { |
| 366 | let entry = entry.unwrap(); |
| 367 | let path = entry.path(); |
| 368 | if entry.file_type().unwrap().is_dir() { |
| 369 | collect(root, &path, out); |
| 370 | } else { |
| 371 | out.insert( |
| 372 | path.strip_prefix(root).unwrap().display().to_string(), |
| 373 | std::fs::read(path).unwrap(), |
| 374 | ); |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | let mut files = std::collections::BTreeMap::new(); |
| 379 | collect(root, &root.join(".atomic"), &mut files); |
| 380 | files |