(path: &Path, contents: &str)
| 195 | } |
| 196 | |
| 197 | fn 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 | |
| 210 | fn sanitize_project_dir_name(name: &str) -> String { |
| 211 | let trimmed = name.trim(); |
no test coverage detected