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

Method add_file

atomic-core/src/record/workflow/crdt/builder/trunk.rs:152–162  ·  view source on GitHub ↗

Adds a new file and returns its trunk ID. Creates a `TrunkOp::Create` for the file. Use [`add_line`](Self::add_line) to add content to the file.

(&mut self, path: &str, encoding: Option<Encoding>)

Source from the content-addressed store, hash-verified

150 /// Creates a `TrunkOp::Create` for the file. Use [`add_line`](Self::add_line)
151 /// to add content to the file.
152 pub fn add_file(&mut self, path: &str, encoding: Option<Encoding>) -> TrunkId {
153 let trunk_id = self.alloc_trunk_id();
154 let file_op = FileOps::create(trunk_id, path.to_string(), encoding);
155
156 let file_idx = self.file_ops.len();
157 self.trunk_index.insert(trunk_id, file_idx);
158 self.file_ops.push(file_op);
159
160 self.stats.files_added += 1;
161 trunk_id
162 }
163
164 /// Adds a new file with content, automatically tokenizing into lines.
165 pub fn add_file_with_content(

Calls 4

alloc_trunk_idMethod · 0.45
lenMethod · 0.45
insertMethod · 0.45
pushMethod · 0.45