A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
External hard disks get the sidebar's eject button (D762)
gelenmedya5f82c745de51
diff --git a/crates/rf-app/src/sidebar_tree.rs b/crates/rf-app/src/sidebar_tree.rsindex aa5d65c0..d4791cef 100644--- a/crates/rf-app/src/sidebar_tree.rs+++ b/crates/rf-app/src/sidebar_tree.rs@@ -288,6 +288,7 @@ fn root_icon_names(kind: RootKind) -> &'static [&'static str] {RootKind::Profile => &["user-home", "folder-home"],RootKind::Fixed => &["drive-harddisk", "drive-harddisk-system"],RootKind::Removable => &["drive-removable-media", "drive-harddisk-usb", "drive-harddisk"],+ RootKind::External => &["drive-harddisk-usb", "drive-harddisk"],RootKind::Network => &["network-server", "folder-remote"],RootKind::Optical => &["drive-optical", "drive-cdrom"],}@@ -354,7 +355,9 @@ impl SidebarTree {specs.push(RootSpec { label: rf_core::history::display_name(&home), path: home, kind: RootKind::Profile });}for d in &places.drives {- specs.push(RootSpec { path: d.root.clone(), label: crate::places::drive_name(d), kind: root_kind(d.kind) });+ // (an external hard disk is a fixed disk to Windows; it gets the eject button all the same, discussion 762)+ let kind = if d.external { RootKind::External } else { root_kind(d.kind) };+ specs.push(RootSpec { path: d.root.clone(), label: crate::places::drive_name(d), kind });}let key: Vec<(PathBuf, String, RootKind)> = specs.iter().map(|s| (s.path.clone(), s.label.clone(), s.kind)).collect();if key == self.last_roots {@@ -725,7 +728,7 @@ impl SidebarTree {Some(RootKind::Removable) => L::Usb,Some(RootKind::Network) => L::Network,Some(RootKind::Optical) => L::Disc3,- Some(RootKind::Fixed) => L::HardDrive,+ Some(RootKind::Fixed | RootKind::External) => L::HardDrive,None if expanded => L::FolderOpen,None => L::Folder,}@@ -825,7 +828,7 @@ impl SidebarTree {let (drop_bg, drop_border) = (p.selection, p.accent);let full_name = deep.then(|| SharedString::from(crate::rtl::display_text(&info.label)));// a USB stick's or a disc's root: "Güvenle çıkar" at the row's end, as in Explorer's navigation pane- let eject_letter = matches!(root, Some(RootKind::Removable | RootKind::Optical))+ let eject_letter = matches!(root, Some(RootKind::Removable | RootKind::Optical | RootKind::External)).then(|| info.path.to_str().and_then(|s| s.chars().next()).filter(|c| c.is_ascii_alphabetic())).flatten();let eject_hover = p.pressed;diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex 55343a6b..c47f3d0c 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -4542,7 +4542,7 @@ impl Workspace {.read(cx).drives.iter()- .find(|d| d.root == path && matches!(d.kind, rf_win::DriveKind::Removable | rf_win::DriveKind::Optical))+ .find(|d| d.root == path && (matches!(d.kind, rf_win::DriveKind::Removable | rf_win::DriveKind::Optical) || d.external)).map(|d| d.letter)})};diff --git a/crates/rf-core/src/navtree.rs b/crates/rf-core/src/navtree.rsindex ae21eb31..c8975ee5 100644--- a/crates/rf-core/src/navtree.rs+++ b/crates/rf-core/src/navtree.rs@@ -30,6 +30,8 @@ pub enum RootKind {Profile,Fixed,Removable,+ /// A fixed disk on an outside bus (an external hard disk): ejected like a removable one.+ External,Network,Optical,}diff --git a/crates/rf-win/src/drives.rs b/crates/rf-win/src/drives.rsindex d850a8c1..bb3b44d6 100644--- a/crates/rf-win/src/drives.rs+++ b/crates/rf-win/src/drives.rs@@ -25,6 +25,9 @@ pub struct Drive {pub total: u64,pub free: u64,pub fs: String,+ /// A fixed disk on an outside bus (USB, FireWire, SD): an external hard disk or SSD. Windows calls it fixed, not removable, and+ /// File Explorer still offers to eject it (discussion 762: the eject button was missing for external hard disks).+ pub external: bool,}impl Drive {@@ -141,7 +144,7 @@ fn list_drives_except(skip: u32) -> Vec<Drive> {if kind == DriveKind::Network {log::info!("drives: {letter}: did not answer in time (a network drive whose server is away?), listed without its name");}- Drive { root: PathBuf::from(format!("{letter}:\\")), letter, label: String::new(), kind, total: 0, free: 0, fs: String::new() }+ Drive { root: PathBuf::from(format!("{letter}:\\")), letter, label: String::new(), kind, total: 0, free: 0, fs: String::new(), external: false }})}).collect();@@ -256,7 +259,15 @@ fn volume_of(letter: char, kind: DriveKind) -> Drive {let _ = GetDiskFreeSpaceExW(PCWSTR(w.as_ptr()), Some(&mut free), Some(&mut total), None);}}- Drive { root: PathBuf::from(root), letter, label: from_wide(&label), kind, total, free, fs: from_wide(&fs) }+ let external = kind == DriveKind::Fixed && external_bus(letter);+ Drive { root: PathBuf::from(root), letter, label: from_wide(&label), kind, total, free, fs: from_wide(&fs), external }+}++/// Whether drive `letter`'s disk sits on an outside bus: USB (7), IEEE 1394 (4), SD (12) or MMC (13). One query of the volume,+/// opened without access rights; nothing is read from the disk.+pub fn external_bus(letter: char) -> bool {+ let q = [0u32.to_le_bytes(), 0u32.to_le_bytes(), [0; 4]].concat();+ storage_query(std::path::Path::new(&format!("{letter}:\\")), &q, 1024).and_then(|d| u32_at(&d, 28)).is_some_and(|b| matches!(b, 4 | 7 | 12 | 13))}#[cfg(test)]