[][src]Function permissions::functions::is_file_removable

pub fn is_file_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_file_removable;
use std::io;

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

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

    Ok(())
}