Thanks to visit codestin.com
Credit goes to docs.rs

is_creatable

Function is_creatable 

Source
pub fn is_creatable(path: impl AsRef<Path>) -> Result<bool>
Expand description

Check if current process has permission to create file.

That is, if the current process has permission of write to the parent directory.

Returns false if there’s no parent directory (because you can’t create the root directory).

This is the same as calling is_removable.

§Errors

§Examples

use permissions::is_creatable;
use std::io;

fn main() -> io::Result<()> {
    println!("{}", is_creatable("src/lib.rs")?);
    println!("{}", is_creatable("/root")?);
    println!("{}", is_creatable("/")?);

    // May return `Err(kind: PermissionDenied)`
    // println!("{}", is_creatable("/root/any")?);

    Ok(())
}