mirror of
https://github.com/mii443/izoli.git
synced 2025-08-22 16:05:40 +00:00
add read fn
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs::{self, File},
|
||||||
|
io::Read,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -25,6 +26,15 @@ impl CGroup {
|
|||||||
fs::create_dir_all(root)
|
fs::create_dir_all(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn read(&self, name: &str) -> Result<String, std::io::Error> {
|
||||||
|
let path = self.get_file_path(name);
|
||||||
|
let mut file = File::open(path)?;
|
||||||
|
let mut buf = String::default();
|
||||||
|
file.read_to_string(&mut buf)?;
|
||||||
|
|
||||||
|
Ok(buf)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn check_status(&self) -> bool {
|
pub fn check_status(&self) -> bool {
|
||||||
let root = self.get_root_path();
|
let root = self.get_root_path();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user