macOS Support (#18)

* replace target_os = "linux" with target_family = "unix"

* check correct dir for macos steam files
This commit is contained in:
Ankush Gupta
2022-03-10 06:21:28 +01:00
committed by GitHub
parent f77f1e6bab
commit c188c6f385
16 changed files with 40 additions and 28 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ impl Platform<ManifestItem, EpicGamesManifestsError> for EpicPlatform {
get_egs_manifests(&self.settings) get_egs_manifests(&self.settings)
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
fn create_symlinks(&self) -> bool { fn create_symlinks(&self) -> bool {
self.settings.create_symlinks self.settings.create_symlinks
} }
+1 -1
View File
@@ -74,7 +74,7 @@ fn get_manifest_dir_path(
} }
pub fn get_default_location() -> Option<PathBuf> { pub fn get_default_location() -> Option<PathBuf> {
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
{ {
//No path defined for epic gamestore, and we cannot guess on linux //No path defined for epic gamestore, and we cannot guess on linux
None None
+1 -1
View File
@@ -148,7 +148,7 @@ mod tests {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
assert_eq!(shortcut.exe, "\"C:\\Games\\MarvelGOTG\\retail/gotg.exe\""); assert_eq!(shortcut.exe, "\"C:\\Games\\MarvelGOTG\\retail/gotg.exe\"");
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
assert_eq!(shortcut.exe, "\"C:\\Games\\MarvelGOTG/retail/gotg.exe\""); assert_eq!(shortcut.exe, "\"C:\\Games\\MarvelGOTG/retail/gotg.exe\"");
assert_eq!(shortcut.launch_options, ""); assert_eq!(shortcut.launch_options, "");
+1 -1
View File
@@ -5,6 +5,6 @@ pub struct EpicGamesLauncherSettings {
pub enabled: bool, pub enabled: bool,
pub location: Option<String>, pub location: Option<String>,
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
pub create_symlinks: bool, pub create_symlinks: bool,
} }
+6 -6
View File
@@ -21,7 +21,7 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
"Gog" "Gog"
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
fn create_symlinks(&self) -> bool { fn create_symlinks(&self) -> bool {
self.settings.create_symlinks self.settings.create_symlinks
} }
@@ -41,7 +41,7 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
return Err(GogErrors::ConfigFileNotFound { path: config_path }); return Err(GogErrors::ConfigFileNotFound { path: config_path });
} }
let install_locations = get_install_locations(config_path)?; let install_locations = get_install_locations(config_path)?;
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
let install_locations = if let Some(wine_c_drive) = &self.settings.wine_c_drive { let install_locations = if let Some(wine_c_drive) = &self.settings.wine_c_drive {
fix_paths(wine_c_drive, install_locations) fix_paths(wine_c_drive, install_locations)
} else { } else {
@@ -113,12 +113,12 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
None => folder_path.to_string(), None => folder_path.to_string(),
}; };
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
let working_dir = working_dir.replace("\\", "/"); let working_dir = working_dir.replace("\\", "/");
let full_path_string = full_path.to_string(); let full_path_string = full_path.to_string();
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
let full_path_string = full_path_string.replace("\\", "/"); let full_path_string = full_path_string.replace("\\", "/");
let shortcut = GogShortcut { let shortcut = GogShortcut {
@@ -151,7 +151,7 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
} }
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
fn fix_paths(wine_c_drive: &str, paths: Vec<String>) -> Vec<String> { fn fix_paths(wine_c_drive: &str, paths: Vec<String>) -> Vec<String> {
paths paths
.iter() .iter()
@@ -191,7 +191,7 @@ pub fn default_location() -> PathBuf {
let program_data = std::env::var(key).expect("Expected a APPDATA variable to be defined"); let program_data = std::env::var(key).expect("Expected a APPDATA variable to be defined");
Path::new(&program_data).join("GOG.com").join("Galaxy") Path::new(&program_data).join("GOG.com").join("Galaxy")
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
{ {
let home = std::env::var("HOME").expect("Expected a home variable to be defined"); let home = std::env::var("HOME").expect("Expected a home variable to be defined");
Path::new(&home).join("Games/gog-galaxy/drive_c/ProgramData/GOG.com/Galaxy") Path::new(&home).join("Games/gog-galaxy/drive_c/ProgramData/GOG.com/Galaxy")
+1 -1
View File
@@ -5,6 +5,6 @@ pub struct GogSettings {
pub enabled: bool, pub enabled: bool,
pub location: Option<String>, pub location: Option<String>,
pub wine_c_drive: Option<String>, pub wine_c_drive: Option<String>,
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
pub create_symlinks: bool, pub create_symlinks: bool,
} }
+2 -2
View File
@@ -55,7 +55,7 @@ impl Platform<ItchGame, ItchErrors> for ItchPlatform {
Ok(res) Ok(res)
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
fn create_symlinks(&self) -> bool { fn create_symlinks(&self) -> bool {
self.settings.create_symlinks self.settings.create_symlinks
} }
@@ -92,7 +92,7 @@ fn dbpath_to_game(paths: &DbPaths<'_>) -> Option<ItchGame> {
}) })
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
pub fn get_default_location() -> String { pub fn get_default_location() -> String {
//If we don't have a home drive we have to just die //If we don't have a home drive we have to just die
let home = std::env::var("HOME").expect("Expected a home variable to be defined"); let home = std::env::var("HOME").expect("Expected a home variable to be defined");
+1 -1
View File
@@ -4,6 +4,6 @@ use serde::{Deserialize, Serialize};
pub struct ItchSettings { pub struct ItchSettings {
pub enabled: bool, pub enabled: bool,
pub location: Option<String>, pub location: Option<String>,
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
pub create_symlinks: bool, pub create_symlinks: bool,
} }
+1 -1
View File
@@ -33,7 +33,7 @@ impl Platform<LegendaryGame, Box<dyn Error>> for LegendaryPlatform {
Ok(legendary_ouput) Ok(legendary_ouput)
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
fn create_symlinks(&self) -> bool { fn create_symlinks(&self) -> bool {
false false
} }
+2 -2
View File
@@ -21,7 +21,7 @@ impl Platform<OriginGame, OriginErrors> for OriginPlatform {
"Origin" "Origin"
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
fn create_symlinks(&self) -> bool { fn create_symlinks(&self) -> bool {
false false
} }
@@ -106,7 +106,7 @@ fn parse_id_from_file(i: &str) -> nom::IResult<&str, &str> {
take_until("&")(i) take_until("&")(i)
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
pub fn get_default_location() -> String { pub fn get_default_location() -> String {
//TODO implement this for linux: //TODO implement this for linux:
// https://www.toptensoftware.com/blog/running-ea-origin-games-under-linux-via-steam-and-proton/ // https://www.toptensoftware.com/blog/running-ea-origin-games-under-linux-via-steam-and-proton/
+1 -1
View File
@@ -12,7 +12,7 @@ where
fn settings_valid(&self) -> SettingsValidity; fn settings_valid(&self) -> SettingsValidity;
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
fn create_symlinks(&self) -> bool; fn create_symlinks(&self) -> bool;
} }
+12
View File
@@ -118,6 +118,18 @@ pub fn get_default_location() -> Result<String, Box<dyn Error>> {
.unwrap_or(""), .unwrap_or(""),
) )
}; };
#[cfg(target_os = "macos")]
let path_string = {
let home = std::env::var("HOME")?;
String::from(
Path::new(&home)
.join("Library")
.join("Application Support")
.join("Steam")
.to_str()
.unwrap_or(""),
)
};
Ok(path_string) Ok(path_string)
} }
+1 -1
View File
@@ -1,4 +1,4 @@
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
mod symlinks; mod symlinks;
mod synchronization; mod synchronization;
+4 -4
View File
@@ -63,9 +63,9 @@ fn fix_shortcut_icons(user: &SteamUsersInfo, shortcuts: &mut Vec<ShortcutOwned>)
.join("config") .join("config")
.join("grid"); .join("grid");
for shortcut in shortcuts { for shortcut in shortcuts {
#[cfg(not(target_os = "linux"))] #[cfg(not(target_family = "unix"))]
let replace_icon = shortcut.icon.trim().eq(""); let replace_icon = shortcut.icon.trim().eq("");
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
let replace_icon = shortcut.icon.trim().eq("") || shortcut.icon.eq(&shortcut.exe); let replace_icon = shortcut.icon.trim().eq("") || shortcut.icon.eq(&shortcut.exe);
if replace_icon { if replace_icon {
let app_id = steam_shortcuts_util::app_id_generator::calculate_app_id( let app_id = steam_shortcuts_util::app_id_generator::calculate_app_id(
@@ -164,7 +164,7 @@ where
return; return;
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
if platform.create_symlinks() { if platform.create_symlinks() {
let name = platform.name(); let name = platform.name();
super::symlinks::ensure_links_folder_created(name); super::symlinks::ensure_links_folder_created(name);
@@ -187,7 +187,7 @@ where
if !shortcut_owned.tags.contains(&boilr_tag) { if !shortcut_owned.tags.contains(&boilr_tag) {
shortcut_owned.tags.push(boilr_tag.clone()); shortcut_owned.tags.push(boilr_tag.clone());
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
let shortcut_owned = if platform.create_symlinks() { let shortcut_owned = if platform.create_symlinks() {
crate::sync::symlinks::create_sym_links(&shortcut_owned) crate::sync::symlinks::create_sym_links(&shortcut_owned)
} else { } else {
+2 -2
View File
@@ -172,12 +172,12 @@ fn update_ui_with_settings(ui: &mut UserInterface, settings: &Settings) {
.unwrap_or(default_gog_location), .unwrap_or(default_gog_location),
); );
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
{ {
ui.gog_winedrive_input ui.gog_winedrive_input
.set_value(&settings.gog.wine_c_drive.clone().unwrap_or("".to_string())); .set_value(&settings.gog.wine_c_drive.clone().unwrap_or("".to_string()));
} }
#[cfg(not(target_os = "linux"))] #[cfg(not(target_family = "unix"))]
{ {
ui.gog_winedrive_input.deactivate(); ui.gog_winedrive_input.deactivate();
} }
+3 -3
View File
@@ -9,7 +9,7 @@ pub struct Uplay {
impl Platform<Game, Box<dyn Error>> for Uplay { impl Platform<Game, Box<dyn Error>> for Uplay {
fn enabled(&self) -> bool { fn enabled(&self) -> bool {
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
{ {
false false
} }
@@ -28,7 +28,7 @@ impl Platform<Game, Box<dyn Error>> for Uplay {
} }
fn get_shortcuts(&self) -> Result<Vec<Game>, Box<dyn Error>> { fn get_shortcuts(&self) -> Result<Vec<Game>, Box<dyn Error>> {
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
{ {
Ok(vec![]) Ok(vec![])
} }
@@ -38,7 +38,7 @@ impl Platform<Game, Box<dyn Error>> for Uplay {
} }
} }
#[cfg(target_os = "linux")] #[cfg(target_family = "unix")]
fn create_symlinks(&self) -> bool { fn create_symlinks(&self) -> bool {
false false
} }