diff options
| author | pml68 <contact@pml68.dev> | 2025-01-11 01:50:16 +0100 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-01-11 01:50:16 +0100 |
| commit | 61926598ce96bee00aafe5340af4a905759b122a (patch) | |
| tree | b79e13b3decc778cc7c66af7187c647ae0a21a52 /iced_builder/src/environment.rs | |
| parent | refactor: apply clippy suggestions (diff) | |
| download | iced-builder-61926598ce96bee00aafe5340af4a905759b122a.tar.gz | |
refactor: remove iced_drop & workspace
Diffstat (limited to 'iced_builder/src/environment.rs')
| -rw-r--r-- | iced_builder/src/environment.rs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/iced_builder/src/environment.rs b/iced_builder/src/environment.rs deleted file mode 100644 index 3ecb790..0000000 --- a/iced_builder/src/environment.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::env; -use std::path::PathBuf; - -pub const CONFIG_FILE_NAME: &str = "config.toml"; - -pub fn config_dir() -> PathBuf { - portable_dir().unwrap_or_else(platform_specific_config_dir) -} - -fn portable_dir() -> Option<PathBuf> { - let exe = env::current_exe().ok()?; - let dir = exe.parent()?; - - dir.join(CONFIG_FILE_NAME) - .is_file() - .then(|| dir.to_path_buf()) -} - -fn platform_specific_config_dir() -> PathBuf { - #[cfg(target_os = "macos")] - { - xdg_config_dir().unwrap_or_else(|| { - dirs_next::config_dir() - .expect("expected valid config dir") - .join("iced-builder") - }) - } - #[cfg(not(target_os = "macos"))] - { - dirs_next::config_dir() - .expect("expected valid config dir") - .join("iced-builder") - } -} - -#[cfg(target_os = "macos")] -fn xdg_config_dir() -> Option<PathBuf> { - let config_dir = xdg::BaseDirectories::with_prefix("iced-builder") - .ok() - .and_then(|xdg| xdg.find_config_file(CONFIG_FILE_NAME))?; - - config_dir.parent().map(|p| p.to_path_buf()) -} |
