Skip to content

Commit

Permalink
Merge pull request #43 from SmilerRyan:beta
Browse files Browse the repository at this point in the history
Add portable configuration option.
  • Loading branch information
DIDIRUS4 authored Nov 16, 2024
2 parents 2cf3b37 + d2dff95 commit 1a7c86b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 14 additions & 1 deletion apps/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,20 @@ fn main() {
.plugin(tauri_plugin_shell::init())
.plugin(
tauri_plugin_window_state::Builder::default()
.with_filename("app-window-state.json")
.with_filename(
if std::env::current_dir()
.ok()
.map(|dir| dir.join("portable.txt").exists())
.unwrap_or(false)
{
std::env::current_dir()
.ok()
.map(|dir| dir.join("UserData/app-window-state.json").to_string_lossy().into_owned())
.unwrap()
} else {
"app-window-state.json".to_string()
},
)
.build(),
)
.setup(|app| {
Expand Down
9 changes: 7 additions & 2 deletions packages/app-lib/src/state/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ impl DirectoryInfo {
// Get the settings directory
// init() is not needed for this function
pub fn get_initial_settings_dir() -> Option<PathBuf> {
Self::env_path("THESEUS_CONFIG_DIR")
.or_else(|| Some(dirs::data_dir()?.join("AstralRinthApp")))
Self::env_path("THESEUS_CONFIG_DIR").or_else(|| {
if std::env::current_dir().ok()?.join("portable.txt").exists() {
Some(std::path::Path::new("UserData").to_path_buf())
} else {
Some(dirs::data_dir()?.join("AstralRinthApp"))
}
})
}

/// Get all paths needed for Theseus to operate properly
Expand Down

0 comments on commit 1a7c86b

Please sign in to comment.