Mercurial > core / rust/lib/util/src/path.rs
changeset 698: |
96958d3eb5b0 |
parent: |
1227f932b628
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
3 //! Helper functions for working with paths on filesystem 6 path::{Component, Path, PathBuf}, 9 /// Given a path provided by the user, determines where generated files 10 /// related to that path should go. 11 // this may be for flate only- move there 12 pub fn local_relative_path<P: AsRef<Path>>(path: P) -> Result<PathBuf, Error> { 13 let mut rel_path = PathBuf::new(); 14 let path = path.as_ref(); 15 for component in path.components() { 17 Component::Prefix(_) | Component::RootDir | Component::CurDir => {} 18 Component::ParentDir => drop(rel_path.pop()), // noop if empty 19 Component::Normal(name) => rel_path.push(name),