Skip to main content

clean_path

Function clean_path 

Source
pub fn clean_path(path: &str) -> String
Expand description

A path as music21’s common.cleanpath leaves it: ~ expanded, made absolute against the working directory and normalized, and environment variables expanded.

A .. is collapsed only where the directories before it exist, as the system would; otherwise the path is joined to the working directory as written.

use music21::common::pathtools::clean_path;

assert_eq!(clean_path("/usr//bin/./lilypond"), "/usr/bin/lilypond");
assert!(clean_path("relative/file.xml").ends_with("/relative/file.xml"));