summaryrefslogtreecommitdiff
path: root/helix-core/src/lib.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-05-09 16:02:53 +0000
committerBlaž Hrastnik2021-05-09 16:02:53 +0000
commit0f77f543e5a7a6be0eabd2d4b72591cdafc7ec71 (patch)
treee4705a2e5f04a3e710d77b26b1533f1b31b2fd45 /helix-core/src/lib.rs
parentd33e8fd3d8fa2062acf697b2feb74877ed309561 (diff)
Determine runtime dir based on executable location or env override.
Diffstat (limited to 'helix-core/src/lib.rs')
-rw-r--r--helix-core/src/lib.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs
index dda9863b..e68dc186 100644
--- a/helix-core/src/lib.rs
+++ b/helix-core/src/lib.rs
@@ -44,6 +44,18 @@ pub(crate) fn find_first_non_whitespace_char(text: RopeSlice, line_num: usize) -
None
}
+pub fn runtime_dir() -> std::path::PathBuf {
+ // runtime env var || dir where binary is located
+ std::env::var("HELIX_RUNTIME")
+ .map(|path| path.into())
+ .unwrap_or_else(|_| {
+ std::env::current_exe()
+ .ok()
+ .and_then(|path| path.parent().map(|path| path.to_path_buf()))
+ .unwrap()
+ })
+}
+
pub fn config_dir() -> std::path::PathBuf {
// TODO: allow env var override
let xdg_dirs =