refactored to remove usage of unwrap
@@ -607,35 +607,37 @@ pub(crate) fn get_system_computation_time() -> ULARGE_INTEGER {
}
pub(crate) fn get_disk_usage(p: &mut Process){
- let r = ProcessDiagnosticInfo::try_get_for_process_id(p.pid as u32).ok();
- if r.is_some(){
- let r = r.unwrap();
- if r.is_some(){
- let du = r.unwrap().get_disk_usage().ok();
- if du.is_some(){
- let du = du.unwrap();
- if du.is_some(){
- let report = du.unwrap().get_report().ok();
- if report.is_some(){
- let report = report.unwrap();
- if report.is_some(){
- let report = report.unwrap();
+ let diag_info = ProcessDiagnosticInfo::try_get_for_process_id(p.pid as u32).ok();
+ match diag_info{
+ Some(diag_info) => match diag_info{
+ Some(diag_info) => match diag_info.get_disk_usage().ok(){
+ Some(disk_usage) => match disk_usage{
+ Some(disk_usage) => match disk_usage.get_report().ok(){
+ Some(report) => match report{
+ Some(report) => {
let read_bytes = report.get_bytes_read_count().ok();
let write_bytes = report.get_bytes_written_count().ok();
- if read_bytes.is_some(){
- p.read_bytes = read_bytes.unwrap() as u64;
- }
- if write_bytes.is_some(){
- p.written_bytes = write_bytes.unwrap() as u64;
- }
- }
- }
- }
- }
-
- }
-
- }
+ match read_bytes{
+ Some(read_bytes) => p.read_bytes = read_bytes as u64,
+ None => {}
+ };
+ match write_bytes{
+ Some(write_bytes) => p.written_bytes = write_bytes as u64,
+ None => {}
+ };
+ },
+ None => {}
+ },
+ None => {}
+ },
+ None => {}
+ },
+ None => {}
+ },
+ None => {}
+ },
+ None => {}
+ };
}
pub(crate) fn compute_cpu_usage(p: &mut Process, nb_processors: u64, now: ULARGE_INTEGER) {
