(path: &Path, dedup: bool)
| 601 | status.code() |
| 602 | )); |
| 603 | } |
| 604 | log_done("User Scripts Clippy Clean"); |
| 605 | Ok(()) |
| 606 | } |
| 607 | |
| 608 | fn resolve_project_res_root(path: &Path, command: &str) -> Result<PathBuf, String> { |
| 609 | let path = path.canonicalize().unwrap_or_else(|_| path.to_path_buf()); |
| 610 | |
| 611 | // `--path` must point at project root. |
| 612 | if path.join("project.toml").exists() { |
| 613 | return Ok(path.join("res")); |
| 614 | } |
| 615 | |
| 616 | Err(format!( |
| 617 | "invalid --path `{}` for {command}. Use project root (directory containing project.toml).", |
| 618 | path.display() |
| 619 | )) |
| 620 | } |
| 621 | |
| 622 | pub(crate) fn collect_rs_files_recursive(dir: &Path, out: &mut Vec<PathBuf>) -> Result<(), String> { |
| 623 | if !dir.exists() { |
| 624 | return Ok(()); |
| 625 | } |
| 626 | let entries = fs::read_dir(dir) |
| 627 | .map_err(|err| format!("failed to read directory {}: {err}", dir.display()))?; |
| 628 | for entry in entries { |
| 629 | let entry = entry |
| 630 | .map_err(|err| format!("failed to read directory entry in {}: {err}", dir.display()))?; |
| 631 | let path = entry.path(); |
| 632 | if path.is_dir() { |
| 633 | collect_rs_files_recursive(&path, out)?; |
| 634 | } else if path.extension().is_some_and(|ext| ext == "rs") { |
| 635 | out.push(path); |
no test coverage detected