[][src]Function permissions::functions::is_removable

pub fn is_removable(path: impl AsRef<Path>) -> Result<bool>

Check if current process has permission to remove file.

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

Returns false if there's no parent directory (because can't delete the system's root).

Errors

Examples

use permissions::is_removable;
use std::io;

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

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

    Ok(())
}