platform-independent configuration file path
This commit is contained in:
parent
0f0d1aa1a9
commit
43756fc09c
51
Cargo.lock
generated
51
Cargo.lock
generated
|
@ -1568,6 +1568,27 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "5.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dispatch"
|
||||
version = "0.2.0"
|
||||
|
@ -2306,6 +2327,16 @@ dependencies = [
|
|||
"redox_syscall 0.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
version = "0.5.6"
|
||||
|
@ -2772,13 +2803,19 @@ version = "1.19.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[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.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166"
|
||||
dependencies = [
|
||||
"libredox",
|
||||
"libredox 0.0.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2789,6 +2826,7 @@ dependencies = [
|
|||
"bevy_embedded_assets",
|
||||
"bevy_xpbd_3d",
|
||||
"blend",
|
||||
"dirs",
|
||||
"embed-resource",
|
||||
"fastrand",
|
||||
"regex",
|
||||
|
@ -3082,6 +3120,17 @@ dependencies = [
|
|||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libredox 0.1.3",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.10.3"
|
||||
|
|
|
@ -31,6 +31,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||
serde_yaml = "0.9"
|
||||
|
||||
# For reading/writing the player's configuration file.
|
||||
dirs = "5.0"
|
||||
toml_edit = { version = "0.22", features = ["serde"] }
|
||||
|
||||
[dependencies.bevy]
|
||||
|
|
16
src/var.rs
16
src/var.rs
|
@ -451,15 +451,13 @@ fn get_prefs_path() -> Option<String> {
|
|||
if file_is_readable(test) {
|
||||
return Some(test.to_string());
|
||||
}
|
||||
if let Ok(basedir) = env::var("XDG_CONFIG_HOME") {
|
||||
let test = basedir.to_string() + "/outfly/" + CONF_FILE;
|
||||
if file_is_readable(test.as_str()) {
|
||||
return Some(test);
|
||||
}
|
||||
} else if let Ok(basedir) = env::var("HOME") {
|
||||
let test = basedir.to_string() + ".config/outfly/" + CONF_FILE;
|
||||
if file_is_readable(test.as_str()) {
|
||||
return Some(test);
|
||||
if let Some(mut conf) = dirs::config_dir() {
|
||||
conf.push("OutFly");
|
||||
conf.push(CONF_FILE);
|
||||
if let Some(test) = conf.to_str() {
|
||||
if file_is_readable(test) {
|
||||
return Some(test.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
return None;
|
||||
|
|
Loading…
Reference in a new issue