(file: Option<&Path>, from: Option<&Path>)
| 5467 | } |
| 5468 | |
| 5469 | fn profile_source_paths(file: Option<&Path>, from: Option<&Path>) -> Result<Vec<PathBuf>> { |
| 5470 | if let Some(file) = file { |
| 5471 | return Ok(vec![file.to_path_buf()]); |
| 5472 | } |
| 5473 | let Some(from) = from else { |
| 5474 | return Ok(Vec::new()); |
| 5475 | }; |
| 5476 | let mut paths = Vec::new(); |
| 5477 | for entry in std::fs::read_dir(from) |
| 5478 | .into_diagnostic() |
| 5479 | .wrap_err_with(|| format!("failed to read profile directory {}", from.display()))? |
| 5480 | { |
| 5481 | let entry = entry.into_diagnostic()?; |
| 5482 | let path = entry.path(); |
| 5483 | if path.is_file() && profile_extension_supported(&path) { |
| 5484 | paths.push(path); |
| 5485 | } |
| 5486 | } |
| 5487 | paths.sort(); |
| 5488 | Ok(paths) |
| 5489 | } |
| 5490 | |
| 5491 | fn profile_extension_supported(path: &Path) -> bool { |
| 5492 | matches!( |
no test coverage detected