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

Method read_file

atomic-core/src/output/memory.rs:516–530  ·  view source on GitHub ↗
(&self, path: &str, buffer: &mut Vec<u8>)

Source from the content-addressed store, hash-verified

514 }
515
516 fn read_file(&self, path: &str, buffer: &mut Vec<u8>) -> Result<(), Self::Error> {
517 let files = self.files.borrow();
518 match files.get(path) {
519 Some(file) if file.metadata.is_dir => Err(MemoryError::IsADirectory {
520 path: path.to_string(),
521 }),
522 Some(file) => {
523 buffer.extend_from_slice(&file.contents);
524 Ok(())
525 }
526 None => Err(MemoryError::NotFound {
527 path: path.to_string(),
528 }),
529 }
530 }
531
532 fn modified_time(&self, path: &str) -> Result<SystemTime, Self::Error> {
533 let files = self.files.borrow();

Callers 4

test_read_fileFunction · 0.45
test_read_file_appendsFunction · 0.45
test_read_file_not_foundFunction · 0.45

Calls 1

getMethod · 0.65

Tested by 4

test_read_fileFunction · 0.36
test_read_file_appendsFunction · 0.36
test_read_file_not_foundFunction · 0.36