Collect files from the working copy. Scans the working copy to find all files present on disk. This is the complement to `collect_tracked_files` for detecting added/deleted files. # Arguments `working_copy` - Working copy interface `prefix` - Path prefix filter (empty = all files) # Returns A `CollectionResult ` containing all working copy files. # Behavior - Walks the working c
(
working_copy: &W,
prefix: &str,
)
| 434 | /// } |
| 435 | /// ``` |
| 436 | pub fn collect_working_files<W>( |
| 437 | working_copy: &W, |
| 438 | prefix: &str, |
| 439 | ) -> RecordResult<CollectionResult<WorkingFile>> |
| 440 | where |
| 441 | W: WorkingCopyRead, |
| 442 | { |
| 443 | let mut result = CollectionResult::new(); |
| 444 | |
| 445 | // Walk the working copy directory tree |
| 446 | let paths = working_copy |
| 447 | .walk_files(prefix) |
| 448 | .map_err(|e| RecordError::Io(std::io::Error::other(e.to_string())))?; |
| 449 | |
| 450 | for path in paths { |
| 451 | let mut file = WorkingFile::new(&path); |
| 452 | |
| 453 | // Check if it's a directory |
| 454 | if working_copy.is_directory(&path) { |
| 455 | file = file.as_directory(); |
| 456 | } |
| 457 | |
| 458 | // Try to get mtime |
| 459 | if let Ok(mtime) = working_copy.modified_time(&path) { |
| 460 | file = file.with_mtime(mtime); |
| 461 | } |
| 462 | |
| 463 | result.add(file); |
| 464 | } |
| 465 | |
| 466 | Ok(result) |
| 467 | } |
| 468 | |
| 469 | /// Collect working copy state for a specific set of paths. |
| 470 | /// |