From eb6426fe0b28dc9afe35db6c20505cc86fcfebc5 Mon Sep 17 00:00:00 2001 From: Saul Rodriguez Date: Mon, 16 Nov 2026 13:20:53 +0100 Subject: [PATCH 1/2] feat(arca-setup): put Arca's ZIP archive under New in the Explorer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Explorer's New menu has one entry per extension, named after the type the extension belongs to. Arca registered itself as an app that opens .zip but left the type to whatever had it, so the entry showed Arca's icon under another archiver's name. With "Open .zip … with Arca" chosen, the installer now makes .zip Arca's type for this user, names it "Arca ZIP archive" in the system's language, and adds a New entry that creates an empty archive. The type .zip had before is recorded and given back when Arca is uninstalled or the option is turned off; the machine-wide registration is never touched. Co-Authored-By: Claude Opus 5.5 --- arca-setup/src/engine/system.rs | 67 +++++++++++++++++++++++++++++++++ arca-setup/src/i18n.rs | 9 ++++- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/arca-setup/src/engine/system.rs b/arca-setup/src/engine/system.rs index 207d6811..83af3909 100644 --- a/arca-setup/src/engine/system.rs +++ b/arca-setup/src/engine/system.rs @@ -189,10 +189,77 @@ pub fn register_associations(dir: &Path) -> Res<()> { r"Software\RegisteredApplications", "Arca", r"Software\Arca\Capabilities", + )?; + own_zip() +} + +/// An archive with nothing in it: the end-of-central-directory record alone. +const EMPTY_ZIP: [u8; 22] = [ + 0x50, 0x4b, 0x05, 0x06, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +const ZIP_CLASS: &str = r"Software\Classes\.zip"; +/// Where the type .zip had before Arca took it, so that uninstalling hands +/// it back. Kept outside `Software\Arca`, which is removed first. +const ZIP_BEFORE: &str = r"Software\Classes\Arca.zip.previous"; + +/// The Explorer's New menu has one entry per extension, named after the type +/// the extension belongs to, so Arca's entry needs `.zip` to be Arca's. Only +/// for this user: the machine-wide type, usually Windows' or another +/// archiver's, stays as it is and comes back when Arca goes. +fn own_zip() -> Res<()> { + let current = hkcu() + .open_subkey(ZIP_CLASS) + .and_then(|key| key.get_value::("")) + .ok(); + if current.as_deref() != Some("Arca.zip") { + delete_tree(ZIP_BEFORE)?; + if let Some(before) = current.filter(|before| !before.is_empty()) { + set(ZIP_BEFORE, "", &before)?; + } else { + set(ZIP_BEFORE, "", "")?; + } + } + let name = crate::i18n::Lang::from_system().strings().zip_type; + set(r"Software\Classes\Arca.zip", "", name)?; + set(ZIP_CLASS, "", "Arca.zip")?; + let (key, _) = hkcu() + .create_subkey(format!(r"{ZIP_CLASS}\Arca.zip\ShellNew")) + .map_err(ctx("registry key .zip\\Arca.zip\\ShellNew"))?; + key.set_raw_value( + "Data", + &RegValue { + bytes: EMPTY_ZIP.to_vec().into(), + vtype: REG_BINARY, + }, ) + .map_err(ctx("registry value ShellNew\\Data")) +} + +/// Hands `.zip` back to whatever had it before `own_zip`, or to the +/// machine-wide type when this user had none of their own. +fn give_back_zip() -> Res<()> { + delete_tree(&format!(r"{ZIP_CLASS}\Arca.zip"))?; + let ours = hkcu() + .open_subkey(ZIP_CLASS) + .and_then(|key| key.get_value::("")) + .is_ok_and(|current| current == "Arca.zip"); + if ours { + let before = hkcu() + .open_subkey(ZIP_BEFORE) + .and_then(|key| key.get_value::("")) + .ok() + .filter(|before| !before.is_empty()); + match before { + Some(before) => set(ZIP_CLASS, "", &before)?, + None => delete_value(ZIP_CLASS, "")?, + } + } + delete_tree(ZIP_BEFORE) } pub fn unregister_associations() -> Res<()> { + give_back_zip()?; for (extension, progid, _) in ASSOCIATIONS { delete_tree(&format!(r"Software\Classes\{progid}"))?; delete_value( diff --git a/arca-setup/src/i18n.rs b/arca-setup/src/i18n.rs index 1630fd50..df1ae9cb 100644 --- a/arca-setup/src/i18n.rs +++ b/arca-setup/src/i18n.rs @@ -41,6 +41,9 @@ pub struct Strings { pub option_menu_hint: &'static str, pub option_assoc: &'static str, pub option_assoc_hint: &'static str, + /// What a .zip is called in the Explorer once Arca owns the type, and + /// the name of its entry under New. + pub zip_type: &'static str, pub option_path: &'static str, pub option_path_hint: &'static str, pub location: &'static str, @@ -80,7 +83,8 @@ static ES: Strings = Strings { option_menu: "Menú contextual del Explorador", option_menu_hint: "Comprimir y extraer con el botón derecho", option_assoc: "Abrir .zip, .7z, .tar, .gz y .tgz con Arca", - option_assoc_hint: "Arca aparece en Aplicaciones predeterminadas", + option_assoc_hint: "Arca aparece en Aplicaciones predeterminadas y en Nuevo", + zip_type: "Archivo ZIP de Arca", option_path: "Añadir el comando arca al PATH", option_path_hint: "Usar Arca desde la terminal", location: "Carpeta de instalación", @@ -130,7 +134,8 @@ static EN: Strings = Strings { option_menu: "Explorer context menu", option_menu_hint: "Compress and extract with a right click", option_assoc: "Open .zip, .7z, .tar, .gz and .tgz with Arca", - option_assoc_hint: "Arca shows up in Default apps", + option_assoc_hint: "Arca shows up in Default apps and under New", + zip_type: "Arca ZIP archive", option_path: "Add the arca command to PATH", option_path_hint: "Use Arca from the terminal", location: "Install location", From 1d00546f8fcd14a744f999129456160955743182 Mon Sep 17 00:00:00 2001 From: Saul Rodriguez Date: Tue, 17 Nov 2026 01:04:26 +0100 Subject: [PATCH 2/2] fix(arca-setup): build on Linux and macOS with the New menu name The name given to Arca's ZIP type and its New menu entry is only read by the Windows registry code, so the installer failed to build with -D warnings on Linux and macOS, where that code is not compiled. Co-Authored-By: Claude Opus 5.5 --- arca-setup/src/i18n.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/arca-setup/src/i18n.rs b/arca-setup/src/i18n.rs index df1ae9cb..d47bca27 100644 --- a/arca-setup/src/i18n.rs +++ b/arca-setup/src/i18n.rs @@ -43,6 +43,7 @@ pub struct Strings { pub option_assoc_hint: &'static str, /// What a .zip is called in the Explorer once Arca owns the type, and /// the name of its entry under New. + #[cfg_attr(not(windows), allow(dead_code))] pub zip_type: &'static str, pub option_path: &'static str, pub option_path_hint: &'static str,