-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
other: remaining changes needed to get android to build
- Loading branch information
1 parent
8116b66
commit 104c36d
Showing
4 changed files
with
216 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//! Fallback disk info using sysinfo. | ||
|
||
use sysinfo::{DiskExt, System, SystemExt}; | ||
|
||
use crate::app::filter::Filter; | ||
|
||
use super::{keep_disk_entry, DiskHarvest}; | ||
|
||
pub(crate) fn get_disk_usage( | ||
sys: &System, disk_filter: &Option<Filter>, mount_filter: &Option<Filter>, | ||
) -> Vec<DiskHarvest> { | ||
let disks = sys.disks(); | ||
disks | ||
.iter() | ||
.filter_map(|disk| { | ||
let name = { | ||
let name = disk.name(); | ||
|
||
if name.is_empty() { | ||
"No Name".to_string() | ||
} else { | ||
name.to_os_string() | ||
.into_string() | ||
.unwrap_or_else(|_| "Name Unavailable".to_string()) | ||
} | ||
}; | ||
|
||
let mount_point = disk | ||
.mount_point() | ||
.as_os_str() | ||
.to_os_string() | ||
.into_string() | ||
.unwrap_or_else(|_| "Mount Unavailable".to_string()); | ||
|
||
if keep_disk_entry(&name, &mount_point, disk_filter, mount_filter) { | ||
let free_space = disk.available_space(); | ||
let total_space = disk.total_space(); | ||
let used_space = total_space - free_space; | ||
|
||
Some(DiskHarvest { | ||
name, | ||
mount_point, | ||
free_space: Some(free_space), | ||
used_space: Some(used_space), | ||
total_space: Some(total_space), | ||
}) | ||
} else { | ||
None | ||
} | ||
}) | ||
.collect() | ||
} |
Oops, something went wrong.