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