docsrs_cli/cache/
paths.rs1use std::path::PathBuf;
4
5pub fn resolve_cache_dir(override_dir: Option<PathBuf>) -> Option<PathBuf> {
13 resolve_cache_dir_with_source(override_dir).0
14}
15
16pub fn resolve_cache_dir_with_source(
18 override_dir: Option<PathBuf>,
19) -> (Option<PathBuf>, crate::config::PathSource) {
20 use crate::config::PathSource;
21 if let Some(p) = override_dir {
22 return (Some(p), PathSource::CliFlag);
23 }
24 if let Some(p) = directories::ProjectDirs::from("", "", crate::config::APP_NAME)
25 .map(|d| d.cache_dir().to_path_buf())
26 {
27 return (Some(p), PathSource::Xdg);
28 }
29 (None, PathSource::Unresolved)
30}