(path: &Path, allow_absolute: bool)
| 678 | } |
| 679 | |
| 680 | fn validate_normal_components(path: &Path, allow_absolute: bool) -> Result<()> { |
| 681 | if path.as_os_str().is_empty() || has_current_dir_segment(path) { |
| 682 | return Err(TraceDecayError::Config { |
| 683 | message: format!("path '{}' is not normalized", path.display()), |
| 684 | }); |
| 685 | } |
| 686 | for component in path.components() { |
| 687 | match component { |
| 688 | Component::Normal(_) => {} |
| 689 | Component::RootDir | Component::Prefix(_) if allow_absolute => {} |
| 690 | Component::CurDir |
| 691 | | Component::ParentDir |
| 692 | | Component::RootDir |
| 693 | | Component::Prefix(_) => { |
| 694 | return Err(TraceDecayError::Config { |
| 695 | message: format!("path '{}' is not normalized", path.display()), |
| 696 | }); |
| 697 | } |
| 698 | } |
| 699 | } |
| 700 | Ok(()) |
| 701 | } |
| 702 | |
| 703 | fn has_current_dir_segment(path: &Path) -> bool { |
| 704 | let text = path.to_string_lossy(); |
no test coverage detected