1use std::path::{Path, PathBuf};
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct HomePaths {
8 pub home: PathBuf,
10 pub registry_dir: PathBuf,
12 pub plugins_dir: PathBuf,
14 pub cache_dir: PathBuf,
16 pub runtime_dir: PathBuf,
18 pub shims_dir: PathBuf,
20 pub sessions_dir: PathBuf,
22 pub global_dir: PathBuf,
24}
25
26pub fn home_paths(home: &Path, runtime_root: &Path) -> HomePaths {
28 HomePaths {
29 home: home.to_path_buf(),
30 registry_dir: home.join("registry"),
31 plugins_dir: home.join("plugins"),
32 cache_dir: home.join("cache"),
33 runtime_dir: runtime_root.to_path_buf(),
34 shims_dir: home.join("shims"),
35 sessions_dir: home.join("sessions"),
36 global_dir: home.join("global"),
37 }
38}
39
40pub fn install_dir(runtime_root: &Path, plugin: &str, version: &str) -> PathBuf {
42 runtime_root.join(plugin).join("versions").join(version)
43}
44
45pub fn global_current_dir(runtime_root: &Path, plugin: &str) -> PathBuf {
47 runtime_root.join(plugin).join("current")
48}
49
50pub fn project_sdk_dir(project_root: &Path, plugin: &str) -> PathBuf {
52 project_root.join(".vs").join("sdks").join(plugin)
53}
54
55pub fn bin_dir(install_dir: &Path) -> PathBuf {
57 install_dir.join("bin")
58}