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 shims_dir: PathBuf,
18 pub sessions_dir: PathBuf,
20 pub global_dir: PathBuf,
22}
23
24pub fn home_paths(home: &Path) -> HomePaths {
26 HomePaths {
27 home: home.to_path_buf(),
28 registry_dir: home.join("registry"),
29 plugins_dir: home.join("plugins"),
30 cache_dir: home.join("cache"),
31 shims_dir: home.join("shims"),
32 sessions_dir: home.join("sessions"),
33 global_dir: home.join("global"),
34 }
35}
36
37pub fn install_dir(home: &Path, plugin: &str, version: &str) -> PathBuf {
39 home.join("cache")
40 .join(plugin)
41 .join("versions")
42 .join(version)
43}
44
45pub fn global_current_dir(home: &Path, plugin: &str) -> PathBuf {
47 home.join("cache").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}