From 617d059eb5f06d967f1a6b22be2ce2325c425b89 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Fri, 19 Jan 2024 22:04:41 -0500 Subject: [PATCH] add missing function --- veilid-server/src/settings.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/veilid-server/src/settings.rs b/veilid-server/src/settings.rs index f2f2c3bc..4acf7816 100644 --- a/veilid-server/src/settings.rs +++ b/veilid-server/src/settings.rs @@ -806,6 +806,28 @@ impl Settings { .unwrap_or_else(|| PathBuf::from("./veilid-server.conf")) } + #[allow(dead_code)] + fn get_or_create_default_directory(subpath: &str) -> PathBuf { + #[cfg(unix)] + if PathBuf::from("/var/db/veilid-server").is_dir() { + let globalpath = PathBuf::from("/var/db/veilid-server").join(subpath); + let _ = std::fs::create_dir_all(&globalpath); + if globalpath.is_dir() { + return globalpath; + } + } + + let mut ts_path = if let Some(my_proj_dirs) = ProjectDirs::from("org", "Veilid", "Veilid") { + PathBuf::from(my_proj_dirs.data_local_dir()) + } else { + PathBuf::from("./") + }; + ts_path.push(subpath); + let _ = std::fs::create_dir_all(&ts_path); + + ts_path + } + pub fn get_default_ipc_directory() -> PathBuf { cfg_if! { if #[cfg(windows)] {