Mountain/IPC/WindServiceHandlers/Extension/UserExtensionDirectory.rs
1#![allow(non_snake_case)]
2//! User-scope install destination for VSIX unpacks. Matches the user-scope
3//! scan path in `Binary/Extension/ScanPathConfigure.rs` so VSIX-installed
4//! extensions are discovered on the next Mountain boot without a sync step.
5//!
6//! Resolution order (honours Atom V1 `Lodge`):
7//! 1. `$Lodge` - explicit per-operator override. Leading `~/` expands against
8//! `$HOME`.
9//! 2. `$HOME/.land/extensions` - VS Code-style user-scope default.
10//! 3. `./extensions` - fallback when `$HOME` is unavailable.
11
12use std::path::PathBuf;
13
14pub fn UserExtensionDirectory() -> PathBuf {
15 if let Ok(Override) = std::env::var("Lodge") {
16 if let Some(Stripped) = Override.strip_prefix("~/") {
17 if let Some(HomeDirectory) = dirs::home_dir() {
18 return HomeDirectory.join(Stripped);
19 }
20 }
21 return PathBuf::from(Override);
22 }
23
24 if let Some(HomeDirectory) = dirs::home_dir() {
25 return HomeDirectory.join(".land/extensions");
26 }
27
28 PathBuf::from("extensions")
29}