Function rif::utils::strip_path [−][src]
pub fn strip_path(
path: &Path,
base_path: Option<PathBuf>
) -> Result<PathBuf, RifError>
Expand description
Strip a target path with a given base path
If no strip path is given, then strip a current working directory from a given path.
Args
path
- Target path to stripbase_path
- Path to strip from target, default is current working directory
Example
// Current working directory is /home/user/test
let target_path = PathBuf::from("/home/user/test/target");
let stripped = strip_path(&target_path, None);
assert_eq!(stripped, PathBuf::from("target"));
let stripped2 = strip_path(&target_path, Some(PathBuf::from("/home/user")));
assert_eq!(stripped, PathBuf::from("test/target"));