MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / create_file

Method create_file

src/test_utils/git_test_utils.rs:130–142  ·  view source on GitHub ↗

Creates a file in the repository with the given content.

(&self, path: &str, content: &str)

Source from the content-addressed store, hash-verified

128
129 /// Creates a file in the repository with the given content.
130 pub fn create_file(&self, path: &str, content: &str) -> Result<()> {
131 let file_path = self.repo_path.join(path);
132
133 // Create parent directories if needed
134 if let Some(parent) = file_path.parent() {
135 fs::create_dir_all(parent)
136 .with_context(|| format!("Failed to create parent directories for {path}"))?;
137 }
138
139 fs::write(&file_path, content).with_context(|| format!("Failed to write file {path}"))?;
140
141 Ok(())
142 }
143
144 /// Reads a file from the repository.
145 pub fn read_file(&self, path: &str) -> Result<String> {

Calls

no outgoing calls

Tested by

no test coverage detected