MCPcopy Create free account
hub / github.com/PerroEngine/Perro / write_new_file

Function write_new_file

perro_source/devtools/perro_cli/src/scaffold.rs:197–208  ·  view source on GitHub ↗
(path: &Path, contents: &str)

Source from the content-addressed store, hash-verified

195}
196
197fn write_new_file(path: &Path, contents: &str) -> Result<(), String> {
198 if path.exists() {
199 return Err(format!("file already exists: {}", path.display()));
200 }
201 if let Some(parent) = path.parent() {
202 fs::create_dir_all(parent)
203 .map_err(|err| format!("failed to create {}: {err}", parent.display()))?;
204 }
205 fs::write(path, contents)
206 .map_err(|err| format!("failed to write {}: {err}", path.display()))?;
207 Ok(())
208}
209
210fn sanitize_project_dir_name(name: &str) -> String {
211 let trimmed = name.trim();

Callers 5

new_dlc_commandFunction · 0.85
new_script_commandFunction · 0.85
new_scene_commandFunction · 0.85
new_animation_commandFunction · 0.85
new_panimtree_commandFunction · 0.85

Calls 2

parentMethod · 0.80
writeFunction · 0.50

Tested by

no test coverage detected