mirror of
https://github.com/NotAShelf/batmon.git
synced 2024-11-01 19:11:17 +00:00
don't check for write perms
This commit is contained in:
parent
17bd6eaf55
commit
3a9d220140
1 changed files with 0 additions and 18 deletions
18
src/main.rs
18
src/main.rs
|
@ -18,14 +18,6 @@ fn has_read_permission<P: AsRef<Path>>(path: P) -> Result<bool, Box<dyn Error>>
|
||||||
Ok(mode & 0o444 != 0)
|
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>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
@ -61,16 +53,6 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
return Err("Permission denied".into());
|
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 status path: {}", bat_status_path);
|
||||||
println!("Battery capacity path: {}", bat_capacity_path);
|
println!("Battery capacity path: {}", bat_capacity_path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue