Skip to main content

Mountain/IPC/WindServiceHandlers/Utilities/
FiddeeRoot.rs

1
2//! `$HOME/.fiddee` - the user-scope dotfile root. Holds VS Code-style
3//! extensions (`~/.fiddee/extensions`), recently-opened workspaces
4//! (`~/.fiddee/workspaces/RecentlyOpened.json`), per-extension storage
5//! (`~/.fiddee/extensionStorage`, `~/.fiddee/globalStorage`), and the
6//! background-daemon log/data trees (`~/.fiddee/logs`, `~/.fiddee/data`).
7//!
8//! Renamed from `~/.land` when the product shipped as FIDDEE; centralised
9//! here so that any future rename touches a single file. All callers
10//! resolve their sub-paths from this atom rather than hard-coding the
11//! leaf string.
12
13use std::path::PathBuf;
14
15/// Leaf directory name. Public so TS-side callers that mirror this value
16/// (`Cocoon/Source/Services/Handler/Extension/Host/Handler.ts` etc.) can
17/// import the constant via a generated header if/when that wiring lands.
18pub const DOTFILE_NAME:&str = ".fiddee";
19
20/// Returns `$HOME/.fiddee` (or `$USERPROFILE\.fiddee` on Windows).
21/// Falls back to a relative `.fiddee` so callers always get a valid
22/// `PathBuf` - matches the previous `$HOME/.land` resolution semantics.
23pub fn Fn() -> PathBuf {
24	if let Some(Home) = dirs::home_dir() {
25		return Home.join(DOTFILE_NAME);
26	}
27
28	if let Ok(Home) = std::env::var("HOME").or_else(|_| std::env::var("USERPROFILE")) {
29		return PathBuf::from(Home).join(DOTFILE_NAME);
30	}
31
32	PathBuf::from(DOTFILE_NAME)
33}