use std::path::PathBuf;
use byte_unit::Byte;
const SUPPORTED_FS: &[&str] = &["ext2", "ext3", "ext4", "vfat", "ntfs", "fuseblk"];
pub fn get_available_mounts() -> Vec<String> {
let mut mounts: Vec<_> = proc_mounts::MountIter::new()
.unwrap()
.map(|mount| mount.unwrap())
.filter(|mount| SUPPORTED_FS.contains(&mount.fstype.as_str()))
.filter_map(|mount| mount.dest.to_str().map(|s| s.to_string()))
.collect();
mounts.sort();
mounts
}
pub fn get_excluded_paths() -> Vec<PathBuf> {
let mut mounts: Vec<_> = proc_mounts::MountIter::new()
.unwrap()
.map(|mount| mount.unwrap())
.filter(|mount| !SUPPORTED_FS.contains(&mount.fstype.as_str()))
.map(|mount| mount.dest)
.collect();
mounts.sort();
let mut excluded = vec![];
for mount in mounts {
if !excluded.iter().any(|p| mount.starts_with(p)) {
excluded.push(mount);
}
}
excluded
}
pub fn get_used_memory() -> Option<Byte> {
let statm = procinfo::pid::statm_self().ok()?;
let bytes = statm.resident * page_size::get();
Some(Byte::from_bytes(bytes as u64))
}