summaryrefslogtreecommitdiffstats
path: root/src/paths.rs
blob: 24336e828a76aebe6738e091e434ba244a0d98da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use dirs_2;

use std::path::PathBuf;

use crate::fail::HResult;

pub fn home_path() -> HResult<PathBuf> {
    let home = dirs_2::home_dir()?;
    Ok(home)
}

pub fn ranger_path() -> HResult<PathBuf> {
    let mut ranger_path = dirs_2::config_dir()?;
    ranger_path.push("ranger/");
    Ok(ranger_path)
}

#[cfg(not(target_os = "macos"))]
pub fn hunter_path() -> HResult<PathBuf> {
    let mut hunter_path = dirs_2::config_dir()?;
    hunter_path.push("hunter/");
    Ok(hunter_path)
}

#[cfg(target_os = "macos")]
pub fn hunter_path() -> HResult<PathBuf> {
    let mut hunter_path = home_path()?;
    hunter_path.push(".config/");
    hunter_path.push("hunter/");
    Ok(hunter_path)
}

pub fn config_path() -> HResult<PathBuf> {
    let mut config_path = hunter_path()?;
    config_path.push("config");
    Ok(config_path)
}

pub fn bindings_path() -> HResult<PathBuf> {
    let mut config_path = hunter_path()?;
    config_path.push("keys");
    Ok(config_path)
}

pub fn bookmark_path() -> HResult<PathBuf> {
    let mut bookmark_path = hunter_path()?;
    bookmark_path.push("bookmarks");
    Ok(bookmark_path)
}

pub fn tagfile_path() -> HResult<PathBuf> {
    let mut tagfile_path = hunter_path()?;
    tagfile_path.push("tags");
    Ok(tagfile_path)
}

pub fn history_path() -> HResult<PathBuf> {
    let mut history_path = hunter_path()?;
    history_path.push("history");
    Ok(history_path)
}

pub fn actions_path() -> HResult<PathBuf> {
    let mut actions_path = hunter_path()?;
    actions_path.push("actions");
    Ok(actions_path)
}

pub fn previewers_path() -> HResult<PathBuf> {
    let mut previewers_path = hunter_path()?;
    previewers_path.push("previewers");
    Ok(previewers_path)
}