From 9a2ed4bf1abd48a95db0ac1c9cb9e7596b68e59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B1=B1=E9=A2=A8=E9=9C=B2?= Date: Wed, 6 Mar 2024 02:48:27 +0900 Subject: [PATCH] Windows: use folders under AppData (#8828) To be honest, I am not sure how to use these directories. But since it is difficult to change these later, if we are going to change them, I think it is time to do. Release Notes: - N/A --- crates/util/src/paths.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs index 27306bcfb7..107f852c91 100644 --- a/crates/util/src/paths.rs +++ b/crates/util/src/paths.rs @@ -8,17 +8,31 @@ use serde::{Deserialize, Serialize}; lazy_static::lazy_static! { pub static ref HOME: PathBuf = dirs::home_dir().expect("failed to determine home directory"); - pub static ref CONFIG_DIR: PathBuf = HOME.join(".config").join("zed"); + pub static ref CONFIG_DIR: PathBuf = if cfg!(target_os = "windows") { + dirs::config_dir() + .expect("failed to determine RoamingAppData directory") + .join("Zed") + } else { + HOME.join(".config").join("zed") + }; pub static ref CONVERSATIONS_DIR: PathBuf = CONFIG_DIR.join("conversations"); pub static ref EMBEDDINGS_DIR: PathBuf = CONFIG_DIR.join("embeddings"); pub static ref THEMES_DIR: PathBuf = CONFIG_DIR.join("themes"); pub static ref LOGS_DIR: PathBuf = if cfg!(target_os = "macos") { HOME.join("Library/Logs/Zed") + } else if cfg!(target_os = "windows") { + dirs::data_local_dir() + .expect("failed to determine LocalAppData directory") + .join("Zed/logs") } else { CONFIG_DIR.join("logs") }; pub static ref SUPPORT_DIR: PathBuf = if cfg!(target_os = "macos") { HOME.join("Library/Application Support/Zed") + } else if cfg!(target_os = "windows") { + dirs::config_dir() + .expect("failed to determine RoamingAppData directory") + .join("Zed") } else { CONFIG_DIR.clone() }; @@ -29,6 +43,10 @@ lazy_static::lazy_static! { pub static ref DB_DIR: PathBuf = SUPPORT_DIR.join("db"); pub static ref CRASHES_DIR: PathBuf = if cfg!(target_os = "macos") { HOME.join("Library/Logs/DiagnosticReports") + } else if cfg!(target_os = "windows") { + dirs::data_local_dir() + .expect("failed to determine LocalAppData directory") + .join("Zed/crashes") } else { CONFIG_DIR.join("crashes") }; @@ -45,7 +63,13 @@ lazy_static::lazy_static! { pub static ref OLD_LOG: PathBuf = LOGS_DIR.join("Zed.log.old"); pub static ref LOCAL_SETTINGS_RELATIVE_PATH: &'static Path = Path::new(".zed/settings.json"); pub static ref LOCAL_TASKS_RELATIVE_PATH: &'static Path = Path::new(".zed/tasks.json"); - pub static ref TEMP_DIR: PathBuf = HOME.join(".cache").join("zed"); + pub static ref TEMP_DIR: PathBuf = if cfg!(target_os = "widows") { + dirs::data_local_dir() + .expect("failed to determine LocalAppData directory") + .join("Temp/Zed") + } else { + HOME.join(".cache").join("zed") + }; } pub trait PathExt {