fn ensure_parent_dir_exists(path: &str) -> Result<()> {
    let p = Path::new(path);

    // a relative path such as '.' or 'somedir' or 'somefile'
    // has an implicit parent.
    if p.is_relative() && p.components().count() == 1 {
        return Ok(());
    }

    if let Some(pa) = p.parent() {
        if pa.is_dir() {
            Ok(())
        } else {
            bail!("No such directory: \"{}\"", pa.display());
        }
    } else {
        // This should never happen.
        Err(eyre!("Parent directory not found for: \"{}\"", p.display()))
    }
}
// Verifies that parent directory of a given path exists.
Verifies that parent directory of a given path exists.
Verifies that parent directory of a given path exists .
fn ensure_parent_dir_exists(path: &str) -> Result<()> {
    let p = Path::new(path);
    // a relative path such as '.' or 'somedir' or 'somefile'
    // has an implicit parent.
    if p.is_relative() && p.components().count() == 1 {
        return Ok(());
    }
    if let Some(pa) = p.parent() {
        if pa.is_dir() {
            Ok(())
        } else {
            bail!("No such directory: \"{}\"", pa.display());
        }
    } else {
        // This should never happen.
        Err(eyre!("Parent directory not found for: \"{}\"", p.display()))
    }
}
fn ensure_parent_dir_exists ( path : & str ) -> Result < ( ) > { let p = Path :: new ( path ) ; // a relative path such as '.' or 'somedir' or 'somefile' // has an implicit parent. if p . is_relative ( ) && p . components ( ) . count ( ) == 1 { return Ok ( ( ) ) ; } if let Some ( pa ) = p . parent ( ) { if pa . is_dir ( ) { Ok ( ( ) ) } else { bail ! ( " \" \" " pa display ( ) ) ; } } else { // This should never happen. Err ( eyre ! ( " \" \" " p display ( ) ) ) } }
Verifies that parent directory of a given path exists.
Verifies that parent directory of a given path exists .
path
&str