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

Method get_file_contents

atomic-core/src/output/memory.rs:377–386  ·  view source on GitHub ↗

Get the raw contents of a file. Returns `None` if the file doesn't exist or is a directory. # Example ```rust use atomic_core::output::Memory; let wc = Memory::new(); wc.add_file("test.txt", b"hello"); let contents = wc.get_file_contents("test.txt").unwrap(); assert_eq!(contents, b"hello"); ```

(&self, path: &str)

Source from the content-addressed store, hash-verified

375 /// assert_eq!(contents, b"hello");
376 /// ```
377 pub fn get_file_contents(&self, path: &str) -> Option<Vec<u8>> {
378 let files = self.files.borrow();
379 files.get(path).and_then(|f| {
380 if f.metadata.is_dir {
381 None
382 } else {
383 Some(f.contents.clone())
384 }
385 })
386 }
387
388 /// Get the inode for a file.
389 ///

Callers 5

test_add_fileFunction · 0.80
test_write_fileFunction · 0.80
test_empty_fileFunction · 0.80
test_binary_fileFunction · 0.80
test_large_fileFunction · 0.80

Calls 2

getMethod · 0.65
cloneMethod · 0.45

Tested by 5

test_add_fileFunction · 0.64
test_write_fileFunction · 0.64
test_empty_fileFunction · 0.64
test_binary_fileFunction · 0.64
test_large_fileFunction · 0.64