Get the working copy state for a single file. Checks if a file exists in the working copy and collects its metadata. # Arguments `working_copy` - Working copy interface `path` - Path to check # Returns `Some(WorkingFile)` if the file exists, `None` otherwise. # Example ```rust,ignore if let Some(working) = get_working_file(&working_copy, "src/main.rs")? { println!("File exists with size {:?
(working_copy: &W, path: &str)
| 586 | /// } |
| 587 | /// ``` |
| 588 | pub fn get_working_file<W>(working_copy: &W, path: &str) -> RecordResult<Option<WorkingFile>> |
| 589 | where |
| 590 | W: WorkingCopyRead, |
| 591 | { |
| 592 | if !working_copy.exists(path) { |
| 593 | return Ok(None); |
| 594 | } |
| 595 | |
| 596 | let mut file = WorkingFile::new(path); |
| 597 | |
| 598 | if working_copy.is_directory(path) { |
| 599 | file = file.as_directory(); |
| 600 | } |
| 601 | |
| 602 | if let Ok(mtime) = working_copy.modified_time(path) { |
| 603 | file = file.with_mtime(mtime); |
| 604 | } |
| 605 | |
| 606 | Ok(Some(file)) |
| 607 | } |
| 608 | |
| 609 | // TESTS |
| 610 |