diff --git a/Cargo.lock b/Cargo.lock index b8a55246..0bcefb81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1016,6 +1016,16 @@ dependencies = [ "dirs-sys", ] +[[package]] +name = "dirs-next" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf36e65a80337bea855cd4ef9b8401ffce06a7baedf2e85ec467b1ac3f6e82b6" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + [[package]] name = "dirs-sys" version = "0.4.1" @@ -1028,6 +1038,17 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -3320,6 +3341,15 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "platform-dirs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e188d043c1a692985f78b5464853a263f1a27e5bd6322bad3a4078ee3c998a38" +dependencies = [ + "dirs-next", +] + [[package]] name = "png" version = "0.17.13" @@ -3533,6 +3563,7 @@ dependencies = [ "once_cell", "open", "parking_lot", + "platform-dirs", "psst-core", "rand", "raw-window-handle", diff --git a/psst-gui/Cargo.toml b/psst-gui/Cargo.toml index 86b6f537..7221b642 100644 --- a/psst-gui/Cargo.toml +++ b/psst-gui/Cargo.toml @@ -24,6 +24,7 @@ log = { version = "0.4.22" } lru = { version = "0.12.5" } once_cell = { version = "1.20.2" } parking_lot = { version = "0.12.3" } +platform-dirs = { version = "0.3.0" } rand = { version = "0.8.5" } regex = { version = "1.11.0" } serde = { version = "1.0.210", features = ["derive", "rc"] } diff --git a/psst-gui/src/data/config.rs b/psst-gui/src/data/config.rs index fe8f8e37..bc6b6b4a 100644 --- a/psst-gui/src/data/config.rs +++ b/psst-gui/src/data/config.rs @@ -8,8 +8,8 @@ use std::{ #[cfg(target_family = "unix")] use std::os::unix::fs::OpenOptionsExt; -use directories::ProjectDirs; use druid::{Data, Lens, Size}; +use platform_dirs::AppDirs; use psst_core::{ cache::mkdir_if_not_exists, connection::Credentials, @@ -125,23 +125,25 @@ impl Default for Config { } impl Config { - fn project_dirs() -> Option { - ProjectDirs::from("", "", APP_NAME) + fn app_dirs() -> Option { + const USE_XDG_ON_MACOS: bool = false; + + AppDirs::new(Some(APP_NAME), USE_XDG_ON_MACOS) } pub fn spotify_local_files_file(username: &str) -> Option { - ProjectDirs::from("", "", "spotify").map(|dirs| { + AppDirs::new(Some("spotify"), false).map(|dir| { let path = format!("Users/{}-user/local-files.bnk", username); - dirs.config_dir().join(path) + dir.config_dir.join(path) }) } pub fn cache_dir() -> Option { - Self::project_dirs().map(|dirs| dirs.cache_dir().to_path_buf()) + Self::app_dirs().map(|dirs| dirs.cache_dir) } pub fn config_dir() -> Option { - Self::project_dirs().map(|dirs| dirs.config_dir().to_path_buf()) + Self::app_dirs().map(|dirs| dirs.config_dir) } fn config_path() -> Option {