usdpl_back/api_common/
dirs.rs

1//! Directories that may be hard to determine when running from the plugin framework's environment
2
3use std::path::PathBuf;
4
5/// The home directory of the user currently running the Steam Deck UI.
6pub fn home() -> Option<PathBuf> {
7    #[cfg(not(any(feature = "decky", feature = "crankshaft")))]
8    let result = crate::api_any::dirs::home();
9    #[cfg(all(feature = "decky", not(any(feature = "crankshaft"))))]
10    let result = crate::api_decky::home()
11        .ok()
12        .map(|x| PathBuf::from(x).join("..").canonicalize().ok())
13        .flatten();
14
15    result
16}
17
18/// The plugin's root folder.
19pub fn plugin() -> Option<PathBuf> {
20    #[cfg(not(any(feature = "decky", feature = "crankshaft")))]
21    let result = None; // TODO
22    #[cfg(all(feature = "decky", not(any(feature = "crankshaft"))))]
23    let result = crate::api_decky::plugin_dir().ok().map(|x| x.into());
24
25    result
26}
27
28/// The recommended log directory
29pub fn log() -> Option<PathBuf> {
30    #[cfg(not(any(feature = "decky", feature = "crankshaft")))]
31    let result = crate::api_any::dirs::log();
32    #[cfg(all(feature = "decky", not(any(feature = "crankshaft"))))]
33    let result = crate::api_decky::log_dir().ok().map(|x| x.into());
34
35    result
36}