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

Method read_file

atomic-core/src/output/filesystem/walk.rs:113–122  ·  view source on GitHub ↗

Read the contents of a file into a buffer. The buffer is **appended to**, not cleared.

(&self, path: &str, buffer: &mut Vec<u8>)

Source from the content-addressed store, hash-verified

111 ///
112 /// The buffer is **appended to**, not cleared.
113 fn read_file(&self, path: &str, buffer: &mut Vec<u8>) -> Result<(), Self::Error> {
114 let abs_path = self.resolve_path(path)?;
115 if fs::symlink_metadata(&abs_path)?.file_type().is_symlink() {
116 buffer.extend_from_slice(fs::read_link(&abs_path)?.as_os_str().as_encoded_bytes());
117 } else {
118 let mut file = File::open(&abs_path)?;
119 file.read_to_end(buffer)?;
120 }
121 Ok(())
122 }
123
124 /// Get the modification time of a file.
125 fn modified_time(&self, path: &str) -> Result<SystemTime, Self::Error> {

Calls 2

openFunction · 0.85
resolve_pathMethod · 0.45