misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux
Rust bittorrent-clientdebriddownload-acceleratordownload-managerdownloadmanagereguifile-downloadergallery-dlidmidm-alternativeinternet-download-managerm3u8-downloadermagnetplaylist-downloaderreal-debridrusttorrent-clientvideo-downloaderyoutube-downloaderyt-dlp
Open folder uses the file manager set up to open folders (#446) (#497)
Ahmed Nefzaoui22fff90d2e06
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 21f47d00..5b744b0c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,10 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see## [Unreleased]+### Fixed++- Windows: **Open folder** on a download opens the folder with the file manager set up to open folders (Directory Opus, for example), instead of always starting Windows Explorer. With Explorer it still selects the file ([#446](https://github.com/anefzaoui/misterdownloadmanager/issues/446)).+## [0.5.2] - 2026-11-09A big fixes release: YouTube and video downloads, crashes and freezes, downloads on slow disks, the Mac helper, plus a Safari extension, far more file types and a few new columns and options.diff --git a/ROADMAP.md b/ROADMAP.mdindex 2b07a139..c0274edd 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -543,6 +543,8 @@ These ship in a later version, when they're ready.([#321](https://github.com/anefzaoui/misterdownloadmanager/issues/321)): fix in review- π **Open folder** on a torrent still downloading([#354](https://github.com/anefzaoui/misterdownloadmanager/issues/354)): fix in review+- π **Open folder** on Windows always starting Explorer, even with another file manager set up+ to open folders ([#446](https://github.com/anefzaoui/misterdownloadmanager/issues/446)): fix in review- π Alt and F10 opening the menu bar with a control focused([#328](https://github.com/anefzaoui/misterdownloadmanager/issues/328)): fix in review- π Crash on Windows when a window opens while MDM falls back from Direct3D to OpenGLdiff --git a/crates/app/src/dialogs.rs b/crates/app/src/dialogs.rsindex 773e1447..c66cacd0 100644--- a/crates/app/src/dialogs.rs+++ b/crates/app/src/dialogs.rs@@ -2426,6 +2426,16 @@ pub fn show_in_folder(path: &Path) {}return;}+ // Another file manager set up to open folders (#446): Explorer's `/select` would start+ // Explorer anyway. The folder goes to the system, which runs that one; it can't be told+ // which file to select in a way every file manager reads.+ if let Some(opener) = crate::win32::folder_opener() {+ tracing::info!("show in folder: folders open with {opener}");+ if let Some(dir) = path.parent().filter(|d| d.is_dir()) {+ crate::launch::open(dir);+ return;+ }+ }// Explorer reads `/select,"C:\a b\c.mp4"` β quoted after the comma. Rust's own quoting// would wrap the whole argument ("/select,C:\a b\c.mp4"), which Explorer doesn't// understand: it opened its default folder for any path with a space (user reportdiff --git a/crates/app/src/win32.rs b/crates/app/src/win32.rsindex fb42fc45..de0349bf 100644--- a/crates/app/src/win32.rs+++ b/crates/app/src/win32.rs@@ -4657,6 +4657,109 @@ mod classic_text {}}+/// The program Windows runs to open folders, when that isn't Explorer (a file manager such as+/// Directory Opus set up to replace it, #446); None for Explorer, or when Windows doesn't say.+pub fn folder_opener() -> Option<String> {+ use windows_sys::Win32::UI::Shell::{ASSOCF_NONE, ASSOCSTR_EXECUTABLE, AssocQueryStringW};+ other_folder_opener(|class, verb| {+ let wide = |s: &str| s.encode_utf16().chain(Some(0)).collect::<Vec<u16>>();+ let class = wide(class);+ let verb = verb.map(wide);+ let mut out = vec![0u16; 1024];+ let mut len = out.len() as u32;+ // SAFETY: the strings end in NUL and outlive the call; `len` is `out`'s size in+ // characters, and the call writes at most that many.+ let hr = unsafe {+ AssocQueryStringW(+ ASSOCF_NONE,+ ASSOCSTR_EXECUTABLE,+ class.as_ptr(),+ verb.as_ref().map_or(std::ptr::null(), |v| v.as_ptr()),+ out.as_mut_ptr(),+ &mut len,+ )+ };+ (hr == 0).then(|| {+ let end = out.iter().position(|&c| c == 0).unwrap_or(out.len());+ String::from_utf16_lossy(&out[..end])+ })+ })+}++/// Who opens a folder, asked of `executable_for(class, verb)` as the shell reads it: a folder is+/// a `Directory` first (where a replacement registers its verb, as the default or as `open`),+/// then a `Folder` (where Windows registers Explorer). An installed program's other verbs there+/// ("Open with Code") are not the default and aren't asked for.+fn other_folder_opener(+ executable_for: impl Fn(&str, Option<&str>) -> Option<String>,+) -> Option<String> {+ let opener = [+ ("Directory", None),+ ("Directory", Some("open")),+ ("Folder", None),+ ]+ .into_iter()+ .find_map(|(class, verb)| executable_for(class, verb))?;+ let name = opener.rsplit(['\\', '/']).next().unwrap_or(&opener);+ (!name.is_empty() && !name.eq_ignore_ascii_case("explorer.exe")).then_some(opener)+}++#[cfg(test)]+mod folder_opener_tests {+ use super::other_folder_opener;++ const EXPLORER: &str = r"C:\Windows\Explorer.exe";+ const OPUS: &str = r"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe";++ /// #446: as Windows is shipped (what `reg query` shows on a clean system), Explorer it is.+ #[test]+ fn explorer_as_shipped_is_no_other_opener() {+ let shipped =+ |c: &str, v: Option<&str>| (c == "Folder" && v.is_none()).then(|| EXPLORER.to_owned());+ assert_eq!(other_folder_opener(shipped), None);+ }++ /// A replacement's default verb on `Directory` wins over Explorer on `Folder`.+ #[test]+ fn a_replacement_on_directory_is_the_opener() {+ let opus = |c: &str, v: Option<&str>| match (c, v) {+ ("Directory", None) => Some(OPUS.to_owned()),+ ("Folder", None) => Some(EXPLORER.to_owned()),+ _ => None,+ };+ assert_eq!(other_folder_opener(opus).as_deref(), Some(OPUS));+ }++ /// One that replaces `Directory`'s `open` verb, or `Folder`'s own.+ #[test]+ fn a_replaced_open_verb_or_folder_is_the_opener() {+ let open = |c: &str, v: Option<&str>| match (c, v) {+ ("Directory", Some("open")) => Some(r"C:\Apps\files.exe".to_owned()),+ ("Folder", None) => Some(EXPLORER.to_owned()),+ _ => None,+ };+ assert_eq!(+ other_folder_opener(open).as_deref(),+ Some(r"C:\Apps\files.exe")+ );+ let folder = |c: &str, v: Option<&str>| {+ (c == "Folder" && v.is_none()).then(|| r"C:\Apps\tc.exe".to_owned())+ };+ assert_eq!(+ other_folder_opener(folder).as_deref(),+ Some(r"C:\Apps\tc.exe")+ );+ }++ /// Explorer written any way stays Explorer; nothing registered, nothing to say.+ #[test]+ fn explorer_any_case_or_no_answer_is_no_other_opener() {+ let upper = |_: &str, _: Option<&str>| Some(r"C:\WINDOWS\EXPLORER.EXE".to_owned());+ assert_eq!(other_folder_opener(upper), None);+ assert_eq!(other_folder_opener(|_, _| None), None);+ }+}+#[cfg(test)]mod classic_text_tests {use egui::FontFamily;