MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / get_working_file

Function get_working_file

atomic-core/src/record/workflow/collect.rs:588–607  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

586/// }
587/// ```
588pub fn get_working_file<W>(working_copy: &W, path: &str) -> RecordResult<Option<WorkingFile>>
589where
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

Calls 5

existsMethod · 0.45
is_directoryMethod · 0.45
as_directoryMethod · 0.45
modified_timeMethod · 0.45
with_mtimeMethod · 0.45