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
- If
Path::canonicalizefails. - Same as
access_syscall.
§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(())
}