Create a file at the given path with the given content.
(path: PathBuf, content: &str)
| 36 | |
| 37 | /// Create a file at the given path with the given content. |
| 38 | fn create(path: PathBuf, content: &str) -> io::Result<PathBuf> { |
| 39 | if let Some(parent) = path.parent() { |
| 40 | create_dir_all(parent)?; |
| 41 | } |
| 42 | let mut f = File::create(&path)?; |
| 43 | f.write_all(content.as_bytes())?; |
| 44 | f.sync_all()?; |
| 45 | |
| 46 | Ok(path) |
| 47 | } |
| 48 | |
| 49 | /// Create an empty file at the given path. |
| 50 | fn empty(path: PathBuf) -> io::Result<PathBuf> { |
no test coverage detected