From 7e748a897918c2ebd4737179239a9653c8953768 Mon Sep 17 00:00:00 2001 From: SadlyNotSappho Date: Mon, 10 Jul 2023 09:02:01 -0700 Subject: [PATCH] add os detection for steam and config --- src/lib.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4d48166..07d0da2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ pub fn get_home() -> String { let home = match std::env::consts::OS { "linux" => std::env::var("HOME").expect("how is there not a $HOME"), "windows" => std::env::var("userprofile") - .expect("yell at me if this doesn't work please i'm not going to touch windows"), + .expect("yell at me if this doesn't work please"), _ => std::env::var("HOME").expect( "if this doesn't work, you're probably on macos, which i literally cannot test on", ), @@ -41,7 +41,23 @@ pub fn create_config(file: &String) -> bool { } } -pub fn get_steam_location() -> () { +pub fn get_steam_location() -> String { + // windows: C:\Program Files (x86)\Steam + // linux: ~/.local/share/Steam + match std::env::consts::OS { + "linux" => String::from(format!("{}/.local/share/Steam", get_home())), + "windows" => String::from("C:\\Program Files (x86)\\Steam"), + _ => panic!("if ya tell me what OS you're on and where your steam location is, i can fix this") + } +} +pub fn get_config_location() -> String { + // windows: ~\AppData\Roaming + // linux: ~/.config + match std::env::consts::OS { + "linux" => String::from(format!("{}/.config", get_home())), + "windows" => String::from(format!("{}\\AppData\\Roaming", get_home())), + _ => String::from(format!("{}/.config", get_home())) + } } pub fn read_config(file: &String) -> Config {