new: remove dirs, replace with simple module

This commit is contained in:
2026-10-09 17:58:18 -04:00
parent ffe0a54cbd
commit 6581049382
7 changed files with 26 additions and 40 deletions
Generated
-38
View File
@@ -1463,27 +1463,6 @@ dependencies = [
"ctutils",
]
[[package]]
name = "dirs"
version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.61.2",
]
[[package]]
name = "dispatch"
version = "0.2.0"
@@ -4750,12 +4729,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
[[package]]
name = "option-ext"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "orbclient"
version = "0.3.55"
@@ -5463,16 +5436,6 @@ dependencies = [
"bitflags 2.13.2",
]
[[package]]
name = "redox_users"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0"
dependencies = [
"libredox",
"thiserror 2.0.21",
]
[[package]]
name = "regex"
version = "1.13.1"
@@ -6862,7 +6825,6 @@ version = "0.1.0"
dependencies = [
"anyhow",
"chrono",
"dirs",
"dotenvy",
"eyeball-im",
"futures-util",
-1
View File
@@ -21,7 +21,6 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
tracing = "0.1.44"
rand = "0.10.3"
dirs = "7.0.0"
hex = "0.4.3"
dotenvy = "0.15.7"
View File
+1
View File
@@ -2,6 +2,7 @@ mod format;
mod session;
mod room;
mod navigation;
mod credentials;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
+2 -1
View File
@@ -4,6 +4,7 @@ use anyhow::{Context, Result, bail};
use serde::{Deserialize, Serialize};
use std::{fs, path::PathBuf};
use crate::helpers;
#[derive(Serialize, Deserialize)]
pub struct SavedSession {
@@ -13,7 +14,7 @@ pub struct SavedSession {
}
pub fn data_dir() -> PathBuf {
let base: PathBuf = dirs::data_dir().unwrap_or_else(|| PathBuf::from("."));
let base: PathBuf = helpers::system::data_dir().unwrap_or_else(|| PathBuf::from("."));
// 'TOFU_DATA_DIR' so you can run several accounts side by side during development.
std::env::var_os("TOFU_DATA_DIR").map_or_else(|| base.join("tofu"), PathBuf::from)
+1
View File
@@ -0,0 +1 @@
pub mod system;
+22
View File
@@ -0,0 +1,22 @@
use std::env;
use std::ffi::OsString;
use std::path::PathBuf;
pub fn is_absolute_path(path: OsString) -> Option<PathBuf> {
let path = PathBuf::from(path);
if path.is_absolute() {
Some(path)
} else {
None
}
}
pub fn home_dir() -> Option<PathBuf> {
env::var("HOME").ok().map(PathBuf::from)
}
pub fn data_dir() -> Option<PathBuf> {
env::var_os("XDG_DATA_HOME")
.and_then(is_absolute_path)
.or_else(|| home_dir().map(|home| home.join(".local/share")))
}