don't check for write perms

This commit is contained in:
raf 2024-01-09 14:01:15 +03:00
parent 17bd6eaf55
commit 3a9d220140
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29

View file

@ -18,14 +18,6 @@ fn has_read_permission<P: AsRef<Path>>(path: P) -> Result<bool, Box<dyn Error>>
Ok(mode & 0o444 != 0)
}
// check if the current user has write permissions for a given path
fn has_write_permission<P: AsRef<Path>>(path: P) -> Result<bool, Box<dyn Error>> {
let metadata = fs::metadata(path.as_ref())?;
let permissions = metadata.permissions();
let mode = permissions.mode();
Ok(mode & 0o222 != 0)
}
fn main() -> Result<(), Box<dyn Error>> {
@ -61,16 +53,6 @@ fn main() -> Result<(), Box<dyn Error>> {
return Err("Permission denied".into());
}
if !has_write_permission(&bat_status_path)? {
println!("No write permission for the battery status path");
return Err("Permission denied".into());
}
if !has_write_permission(&bat_capacity_path)? {
println!("No write permission for the battery capacity path");
return Err("Permission denied".into());
}
println!("Battery status path: {}", bat_status_path);
println!("Battery capacity path: {}", bat_capacity_path);