MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / normalize_path

Function normalize_path

crates/chat-cli/src/util/paths.rs:176–190  ·  view source on GitHub ↗

Manually normalize a path by resolving . and .. components

(path: &std::path::Path)

Source from the content-addressed store, hash-verified

174
175/// Manually normalize a path by resolving . and .. components
176fn normalize_path(path: &std::path::Path) -> std::path::PathBuf {
177 let mut components = Vec::new();
178 for component in path.components() {
179 match component {
180 std::path::Component::CurDir => {},
181 std::path::Component::ParentDir => {
182 components.pop();
183 },
184 _ => {
185 components.push(component);
186 },
187 }
188 }
189 components.iter().collect()
190}
191
192/// Given a globset builder and a path, build globs for both the file and directory patterns
193/// This is needed because by default glob does not match children of a dir so we need both

Callers 1

canonicalizes_pathFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected