mirror of
https://github.com/RGBCube/superfreq
synced 2025-07-28 01:17:45 +00:00
battery: remove writable path checker
This commit is contained in:
parent
2a5c00e3a7
commit
cd68ffd054
3 changed files with 0 additions and 27 deletions
|
@ -262,24 +262,3 @@ fn is_battery(path: &Path) -> Result<bool> {
|
||||||
|
|
||||||
Ok(ps_type == "Battery")
|
Ok(ps_type == "Battery")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a directory is writable by attempting to open a temporary file for writing
|
|
||||||
fn is_path_writable(path: &Path) -> bool {
|
|
||||||
use std::fs::OpenOptions;
|
|
||||||
|
|
||||||
// Try to create a temporary file to check write permissions
|
|
||||||
// If we're in a container with a read-only mount, this will fail
|
|
||||||
let temp_file_path = path.join(".superfreq_write_test");
|
|
||||||
let result = OpenOptions::new()
|
|
||||||
.write(true)
|
|
||||||
.create(true)
|
|
||||||
.open(&temp_file_path);
|
|
||||||
|
|
||||||
// Clean up the temporary file if we created it
|
|
||||||
if result.is_ok() {
|
|
||||||
let _ = fs::remove_file(temp_file_path);
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::core::{GovernorOverrideMode, TurboSetting};
|
use crate::core::{GovernorOverrideMode, TurboSetting};
|
||||||
use crate::util::error::ControlError;
|
use crate::util::error::ControlError;
|
||||||
use core::str;
|
use core::str;
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::{fs, io, path::Path, string::ToString};
|
use std::{fs, io, path::Path, string::ToString};
|
||||||
|
|
||||||
pub type Result<T, E = ControlError> = std::result::Result<T, E>;
|
pub type Result<T, E = ControlError> = std::result::Result<T, E>;
|
||||||
|
@ -140,7 +139,6 @@ fn get_available_governors() -> Result<Vec<String>> {
|
||||||
let path = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors";
|
let path = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors";
|
||||||
|
|
||||||
if !Path::new(path).exists() {
|
if !Path::new(path).exists() {
|
||||||
|
|
||||||
return Err(ControlError::NotSupported(
|
return Err(ControlError::NotSupported(
|
||||||
"Could not determine available governors".to_string(),
|
"Could not determine available governors".to_string(),
|
||||||
));
|
));
|
||||||
|
|
|
@ -11,7 +11,6 @@ pub enum ControlError {
|
||||||
InvalidProfile(String),
|
InvalidProfile(String),
|
||||||
InvalidGovernor(String),
|
InvalidGovernor(String),
|
||||||
ParseError(String),
|
ParseError(String),
|
||||||
ReadError(String),
|
|
||||||
PathMissing(String),
|
PathMissing(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +46,6 @@ impl std::fmt::Display for ControlError {
|
||||||
Self::ParseError(s) => {
|
Self::ParseError(s) => {
|
||||||
write!(f, "Failed to parse value: {s}")
|
write!(f, "Failed to parse value: {s}")
|
||||||
}
|
}
|
||||||
Self::ReadError(s) => {
|
|
||||||
write!(f, "Failed to read sysfs path: {s}")
|
|
||||||
}
|
|
||||||
Self::PathMissing(s) => {
|
Self::PathMissing(s) => {
|
||||||
write!(f, "Path missing: {s}")
|
write!(f, "Path missing: {s}")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue