|
@@ -32,13 +32,10 @@ use ansiterm::{ANSIStrings, Style};
|
|
|
|
|
|
|
|
use log::*;
|
|
use log::*;
|
|
|
|
|
|
|
|
-#[cfg(target_os = "linux")]
|
|
|
|
|
-use proc_mounts::MountList;
|
|
|
|
|
-
|
|
|
|
|
#[macro_use]
|
|
#[macro_use]
|
|
|
extern crate lazy_static;
|
|
extern crate lazy_static;
|
|
|
|
|
|
|
|
-use crate::fs::mounts::MountedFs;
|
|
|
|
|
|
|
+use crate::fs::mounts;
|
|
|
use crate::fs::{Dir, File};
|
|
use crate::fs::{Dir, File};
|
|
|
use crate::fs::feature::git::GitCache;
|
|
use crate::fs::feature::git::GitCache;
|
|
|
use crate::fs::filter::GitIgnore;
|
|
use crate::fs::filter::GitIgnore;
|
|
@@ -56,33 +53,25 @@ mod theme;
|
|
|
// A lazily initialised static map of all mounted file systems.
|
|
// A lazily initialised static map of all mounted file systems.
|
|
|
//
|
|
//
|
|
|
// The map contains a mapping from the mounted directory path to the
|
|
// The map contains a mapping from the mounted directory path to the
|
|
|
-// corresponding mount information. On Linux systems, this map is populated
|
|
|
|
|
-// using the `proc-mounts` crate. If there's an error retrieving the mount
|
|
|
|
|
-// list or if we're not running on Linux, the map will be empty.
|
|
|
|
|
|
|
+// corresponding mount information. If there's an error retrieving the mount
|
|
|
|
|
+// list or if we're not running on Linux or Mac, the map will be empty.
|
|
|
//
|
|
//
|
|
|
// Initialise this at application start so we don't have to look the details
|
|
// Initialise this at application start so we don't have to look the details
|
|
|
// up for every directory. Ideally this would only be done if the --mounts
|
|
// up for every directory. Ideally this would only be done if the --mounts
|
|
|
// option is specified which will be significantly easier once the move
|
|
// option is specified which will be significantly easier once the move
|
|
|
// to `clap` is complete.
|
|
// to `clap` is complete.
|
|
|
lazy_static! {
|
|
lazy_static! {
|
|
|
- static ref ALL_MOUNTS: HashMap<PathBuf, MountedFs> = {
|
|
|
|
|
- #[cfg(target_os = "linux")]
|
|
|
|
|
- match MountList::new() {
|
|
|
|
|
- Ok(mount_list) => {
|
|
|
|
|
- let mut m = HashMap::new();
|
|
|
|
|
- mount_list.0.iter().for_each(|mount| {
|
|
|
|
|
- m.insert(mount.dest.clone(), MountedFs {
|
|
|
|
|
- dest: mount.dest.to_string_lossy().into_owned(),
|
|
|
|
|
- fstype: mount.fstype.clone(),
|
|
|
|
|
- source: mount.source.to_string_lossy().into(),
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- m
|
|
|
|
|
|
|
+ static ref ALL_MOUNTS: HashMap<PathBuf, mounts::MountedFs> = {
|
|
|
|
|
+ let mut mount_map: HashMap<PathBuf, mounts::MountedFs> = HashMap::new();
|
|
|
|
|
+
|
|
|
|
|
+ #[cfg(any(target_os = "linux", target_os = "macos"))]
|
|
|
|
|
+ if let Ok(mounts) = mounts::mounts() {
|
|
|
|
|
+ for mount in mounts {
|
|
|
|
|
+ mount_map.insert(mount.dest.clone(), mount);
|
|
|
}
|
|
}
|
|
|
- Err(_) => HashMap::new()
|
|
|
|
|
}
|
|
}
|
|
|
- #[cfg(not(target_os = "linux"))]
|
|
|
|
|
- HashMap::new()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ mount_map
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|