Create symlinks on linux

This commit is contained in:
Philip Kristoffersen
2021-10-06 10:00:57 +02:00
parent 206d900ef1
commit 53021a177a
11 changed files with 109 additions and 12 deletions
+7 -7
View File
@@ -21,6 +21,11 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
"Gog"
}
#[cfg(target_os = "linux")]
fn create_symlinks(&self) -> bool {
self.settings.create_symlinks
}
fn get_shortcuts(&self) -> Result<Vec<GogShortcut>, GogErrors> {
let gog_location = self
.settings
@@ -36,14 +41,13 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
return Err(GogErrors::ConfigFileNotFound { path: config_path });
}
let install_locations = get_install_locations(config_path)?;
#[cfg(target_os = "linux")]
let install_locations = if let Some(wine_c_drive) = &self.settings.wine_c_drive {
fix_paths(&wine_c_drive, install_locations)
} else {
install_locations
};
dbg!(&install_locations);
let mut game_folders = vec![];
for install_location in install_locations {
let path = Path::new(&install_location);
@@ -143,11 +147,8 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
}
}
#[cfg(target_os = "linux")]
fn fix_paths(wine_c_drive: &String, paths: Vec<String>) -> Vec<String> {
#[cfg(not(target_os = "linux"))]
return paths;
#[cfg(target_os = "linux")]
{
paths
.iter()
.flat_map(|path| {
@@ -159,7 +160,6 @@ fn fix_paths(wine_c_drive: &String, paths: Vec<String>) -> Vec<String> {
}
})
.collect()
}
}
fn get_install_locations(path: PathBuf) -> Result<Vec<String>, GogErrors> {
+4 -1
View File
@@ -4,5 +4,8 @@ use serde::{Deserialize, Serialize};
pub struct GogSettings {
pub enabled: bool,
pub location: Option<String>,
pub wine_c_drive: Option<String>
pub wine_c_drive: Option<String>,
#[cfg(target_os = "linux")]
pub create_symlinks: bool,
}