fn add_or_create(path: &str, uj_value: u64) -> io::Result<()> {
        let mut content = 0;
        if fs::read_dir(path).is_err() {
            match fs::create_dir_all(path) {
                Ok(_) => info!("Created {} folder.", path),
                Err(error) => panic!("Couldn't create {}. Got: {}", path, error),
            }
        }
        let file_path = format!("{}/{}", path, "energy_uj");
        if let Ok(file) = fs::read_to_string(&file_path) {
            content = file.parse::<u64>().unwrap();
            content += uj_value;
        }
        fs::write(file_path, content.to_string())
    }
/// Either creates an energy_uj file (as the ones managed by powercap kernel module)
/// in 'path' and adds 'uj_value' to its numerical content, or simply performs the
/// addition if the file exists.
Either creates an energy_uj file (as the ones managed by powercap kernel module)
in 'path' and adds 'uj_value' to its numerical content, or simply performs the
addition if the file exists.
Either creates an energy_uj file ( as the ones managed by powercap kernel module ) in ' path ' and adds ' uj_value ' to its numerical content or simply performs the addition if the file exists .
fn add_or_create(path: &str, uj_value: u64) -> io::Result<()> {
        let mut content = 0;
        if fs::read_dir(path).is_err() {
            match fs::create_dir_all(path) {
                Ok(_) => info!("Created {} folder.", path),
                Err(error) => panic!("Couldn't create {}. Got: {}", path, error),
            }
        }
        let file_path = format!("{}/{}", path, "energy_uj");
        if let Ok(file) = fs::read_to_string(&file_path) {
            content = file.parse::<u64>().unwrap();
            content += uj_value;
        }
        fs::write(file_path, content.to_string())
    }
fn add_or_create ( path : & str , uj_value : u64 ) -> io :: Result < ( ) > { let mut content = 0 ; if fs :: read_dir ( path ) . is_err ( ) { match fs :: create_dir_all ( path ) { Ok ( _ ) => info ! ( " " path ) , Err ( error ) => panic ! ( " " path error ) , } } let file_path = format ! ( " " path " " ) ; if let Ok ( file ) = fs :: read_to_string ( & file_path ) { content = file . parse :: < u64 > ( ) . unwrap ( ) ; content += uj_value ; } fs :: write ( file_path , content . to_string ( ) ) }
Either creates an energy_uj file (as the ones managed by powercap kernel module)
in 'path' and adds 'uj_value' to its numerical content, or simply performs the
addition if the file exists.
Either creates an energy_uj file ( as the ones managed by powercap kernel module ) in ' path ' and adds ' uj_value ' to its numerical content or simply performs the addition if the file exists .
path
&str
uj_value
u64
path
&str
uj_value
u64