Compare commits
No commits in common. "4ec3c557fd21ed496fb3551e032770746d3200aa" and "6949f0b52de1d8424a835e1d974626843da1385f" have entirely different histories.
4ec3c557fd
...
6949f0b52d
28
src/lib.rs
28
src/lib.rs
|
@ -10,7 +10,8 @@ pub struct ConfigFile {
|
||||||
pub fn get_home() -> String {
|
pub fn get_home() -> String {
|
||||||
let home = match std::env::consts::OS {
|
let home = match std::env::consts::OS {
|
||||||
"linux" => std::env::var("HOME").expect("how is there not a $HOME"),
|
"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"),
|
"windows" => std::env::var("userprofile")
|
||||||
|
.expect("yell at me if this doesn't work please i'm not going to touch windows"),
|
||||||
_ => std::env::var("HOME").expect(
|
_ => std::env::var("HOME").expect(
|
||||||
"if this doesn't work, you're probably on macos, which i literally cannot test on",
|
"if this doesn't work, you're probably on macos, which i literally cannot test on",
|
||||||
),
|
),
|
||||||
|
@ -32,9 +33,7 @@ pub fn create_config(file: &String) -> bool {
|
||||||
};
|
};
|
||||||
|
|
||||||
if file_path.exists() && !Path::new(&replaced).exists() {
|
if file_path.exists() && !Path::new(&replaced).exists() {
|
||||||
let config = get_config_location();
|
let file_contents = "{{ \"archives\": \"{{CONFIG}/CyberModManager/Archives\", \"folders\": \"{{CONFIG}/CyberModManager/Mods\", \"game_folder\": \"{{STEAM}/steamapps/common/Cyberpunk 2077\"}";
|
||||||
let steam = get_steam_location();
|
|
||||||
let file_contents = format!("{{ \"archives\": \"{}/CyberModManager/Archives\", \"folders\": \"{}/CyberModManager/Mods\", \"game_folder\": \"{}/steamapps/common/Cyberpunk 2077\"}}", config, config, steam);
|
|
||||||
fs::write(replaced, file_contents).expect("couldn't write to config file");
|
fs::write(replaced, file_contents).expect("couldn't write to config file");
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,25 +41,7 @@ pub fn create_config(file: &String) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_steam_location() -> String {
|
pub fn get_steam_location() -> () {
|
||||||
// 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 {
|
pub fn read_config(file: &String) -> Config {
|
||||||
|
@ -80,3 +61,4 @@ pub struct Config {
|
||||||
pub latest_date: String,
|
pub latest_date: String,
|
||||||
pub cache_folder: String,
|
pub cache_folder: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue