use std::path::{Path, PathBuf};
use super::paths::normalize_for_policy;
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
pub(crate) fn sandbox_user_home_dir() -> Option<PathBuf> {
crate::user_dirs::home_dir().filter(|path| path.is_absolute())
}
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
pub(crate) fn developer_toolchain_read_roots_for_home(home: &Path) -> Vec<PathBuf> {
let mut roots: Vec<_> = [
".asdf",
".bun",
".cargo",
".fnm",
".juliaup",
".local/bin",
".local/share/mise",
".local/share/uv",
".nvm",
".pyenv",
".rbenv",
".rustup",
".sdkman",
".swiftly",
".volta",
"go",
]
.into_iter()
.map(|entry| normalize_for_policy(&home.join(entry)))
.collect();
#[cfg(target_os = "windows")]
roots.extend(
[
"AppData/Local/Programs/Python",
"AppData/Local/uv",
"AppData/Roaming/uv",
"scoop",
]
.into_iter()
.map(|entry| normalize_for_policy(&home.join(entry))),
);
roots.sort_unstable();
roots.dedup();
roots
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
pub(crate) fn developer_toolchain_cache_write_roots_for_home(home: &Path) -> Vec<PathBuf> {
let mut roots: Vec<_> = [
".gradle", ".m2", ".konan", "Library/Caches/CocoaPods", "Library/Developer/Xcode/DerivedData", "Library/Caches/go-build", ".cache/go-build", "go/pkg/mod", "Library/Caches/harn", ".cache/harn", "Library/Application Support/go", ".cargo/registry", ".cargo/git", ".cargo/.package-cache", ]
.into_iter()
.map(|entry| normalize_for_policy(&home.join(entry)))
.collect();
roots.sort_unstable();
roots.dedup();
roots
}
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
pub(crate) fn package_manager_config_read_roots_for_home(home: &Path) -> Vec<PathBuf> {
let mut roots: Vec<_> = [
".npmrc",
".gitconfig",
".netrc",
".yarnrc.yml",
".config",
".npm",
".cache",
".pip",
".pypirc",
".cargo/config",
".cargo/config.toml",
".cargo/credentials",
".cargo/credentials.toml",
]
.into_iter()
.map(|entry| normalize_for_policy(&home.join(entry)))
.collect();
roots.sort_unstable();
roots.dedup();
roots
}