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

Method write_file

atomic-core/src/output/filesystem/mod.rs:290–307  ·  view source on GitHub ↗

Open a file for writing, creating it if necessary.

(&self, path: &str, inode: Inode)

Source from the content-addressed store, hash-verified

288
289 /// Open a file for writing, creating it if necessary.
290 fn write_file(&self, path: &str, inode: Inode) -> Result<Self::Writer, Self::Error> {
291 let abs_path = self.resolve_path(path)?;
292
293 // Create parent directories
294 if let Some(parent) = abs_path.parent() {
295 if !parent.exists() {
296 fs::create_dir_all(parent)?;
297 }
298 }
299
300 let file = OpenOptions::new()
301 .write(true)
302 .create(true)
303 .truncate(true)
304 .open(&abs_path)?;
305
306 Ok(FileWriter::new(file, abs_path, inode))
307 }
308}

Callers 10

output_file_with_filterFunction · 0.45
test_write_file_simpleFunction · 0.45
test_write_file_binaryFunction · 0.45
test_file_writer_inodeFunction · 0.45
test_file_writer_pathFunction · 0.45
test_file_writer_finishFunction · 0.45
test_full_workflowFunction · 0.45

Calls 7

parentMethod · 0.80
truncateMethod · 0.80
resolve_pathMethod · 0.45
existsMethod · 0.45
openMethod · 0.45
createMethod · 0.45
writeMethod · 0.45

Tested by 9

test_write_file_simpleFunction · 0.36
test_write_file_binaryFunction · 0.36
test_file_writer_inodeFunction · 0.36
test_file_writer_pathFunction · 0.36
test_file_writer_finishFunction · 0.36
test_full_workflowFunction · 0.36