Skip to main content

default_root_temp_dir

Function default_root_temp_dir 

Source
pub fn default_root_temp_dir(
    system_temp: &Path,
    user: Option<u32>,
    accessible: impl Fn(&Path) -> bool,
) -> Result<PathBuf>
Expand description

A directory for music21’s temporary files under system_temp, as music21’s getDefaultRootTempDir picks it: music21 there, then music21-userid-<user> where a user is given, each made if missing and used only if is_safe_temp_dir; failing both, a new directory named music21- and something random.

use music21::environment::{default_root_temp_dir, is_accessible};

let system = std::env::temp_dir();
let found = default_root_temp_dir(&system, None, is_accessible).unwrap();
assert!(found.starts_with(&system));