diff options
author | Daniel <kingdread@gmx.de> | 2020-05-03 17:34:28 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-05-03 17:34:28 +0200 |
commit | 18544e32ecd1d3bc3535214f0c2edca38346e3a5 (patch) | |
tree | 3334b84a9bb014dcf5ffc768148ecd295afb78b2 /src/paths.rs | |
parent | 913bc8c547e97a785cf1cd9fc20f8377f898da2c (diff) | |
download | raidgrep-18544e32ecd1d3bc3535214f0c2edca38346e3a5.tar.gz raidgrep-18544e32ecd1d3bc3535214f0c2edca38346e3a5.tar.bz2 raidgrep-18544e32ecd1d3bc3535214f0c2edca38346e3a5.zip |
save REPL history to a file
This persists the REPL history across program restarts.
The code should probably be cleaned up a bit more, the error handling in
this one is a bit all over the place. This is because we don't want to
make it a hard error in case the history cannot be saved.
Diffstat (limited to 'src/paths.rs')
-rw-r--r-- | src/paths.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/paths.rs b/src/paths.rs new file mode 100644 index 0000000..f219dc4 --- /dev/null +++ b/src/paths.rs @@ -0,0 +1,19 @@ +//! Module to resolve application-specific paths. +use super::APP_NAME; + +use std::path::PathBuf; + +/// Returns the path that should be used for the cache. +pub fn cache_path() -> PathBuf { + let mut cache_path = dirs::cache_dir().unwrap(); + cache_path.push(APP_NAME); + cache_path +} + +/// Returns the path that should be used for the REPL history. +pub fn history_path() -> Option<PathBuf> { + let mut config_path = dirs::config_dir()?; + config_path.push(APP_NAME); + config_path.push("history"); + Some(config_path) +} |