(dir: &Path)
| 3938 | } |
| 3939 | |
| 3940 | fn clear_directory_contents(dir: &Path) -> Result<(), String> { |
| 3941 | if !dir.exists() { |
| 3942 | return Ok(()); |
| 3943 | } |
| 3944 | for entry in fs::read_dir(dir).map_err(|err| format!("read {}: {err}", dir.display()))? { |
| 3945 | let entry = entry.map_err(|err| format!("read {}: {err}", dir.display()))?; |
| 3946 | remove_path_if_exists(&entry.path())?; |
| 3947 | } |
| 3948 | Ok(()) |
| 3949 | } |
| 3950 | |
| 3951 | fn remove_path_if_exists(path: &Path) -> Result<(), String> { |
| 3952 | let Ok(metadata) = fs::symlink_metadata(path) else { |
no test coverage detected