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