blob: b7fdf91ecb8676bbe8a544a04488cd169e53d4b3 (
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
|
//! Directory and file paths used by iris.
use std::path::PathBuf;
/// Root of the data directory
fn base_config_dir() -> PathBuf {
dirs::config_local_dir().expect("could not locate config directory")
}
/// Root of the config directory
fn base_data_dir() -> PathBuf {
dirs::data_local_dir().expect("could not locate data directory")
}
/// Path to the current diectort
pub fn current_dir() -> PathBuf {
std::env::current_dir().expect("could not locate current directory")
}
/// Path to iris's config directory.
///
/// This is the directory where iris will look and save it's config files.
pub fn config_dir() -> PathBuf {
base_config_dir().join("iris")
}
/// Default path to iris's plugin file
pub fn default_plugin_file() -> PathBuf {
config_dir().join("iris.toml")
}
/// Path to iris's plugin file
pub fn plugin_file() -> PathBuf {
[current_dir(), config_dir()]
.into_iter()
.map(|dir| dir.join("iris.toml"))
.find(|path| path.exists())
.unwrap_or_else(default_plugin_file)
}
/// Path to iris's lock file
pub fn lock_file() -> PathBuf {
plugin_file().with_file_name("iris.lock")
}
/// Path to iris's data directory.
pub fn data_dir() -> PathBuf {
base_data_dir().join("iris")
}
/// Path to iris's plugin directory.
///
/// This is where each checkout for each plugin repository will be saved.
pub fn plugin_dir() -> PathBuf {
data_dir().join("plugins")
}
/// Path to iris's transaction lock file.
///
/// The transaction lock ensures that only one process is operating on iris's
/// data directory at a time.
pub fn transaction_lock_file() -> PathBuf {
data_dir().join("lock")
}
/// Destination path for iris's vim autoload file.
pub fn autoload_file() -> PathBuf {
base_data_dir().join("nvim/site/autoload/iris.vim")
}
|