MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / validate_normal_components

Function validate_normal_components

src/storage.rs:680–701  ·  view source on GitHub ↗
(path: &Path, allow_absolute: bool)

Source from the content-addressed store, hash-verified

678}
679
680fn 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
703fn has_current_dir_segment(path: &Path) -> bool {
704 let text = path.to_string_lossy();

Callers 1

resolveMethod · 0.85

Calls 2

has_current_dir_segmentFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected