Skip to content

Commit

Permalink
Fixed linux version
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Jul 12, 2023
1 parent 7795eb7 commit 980fb2d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod utils;
use directories::BaseDirs;
use minisign::{PublicKeyBox, SignatureBox};
use std::fs::{self, remove_file};
use std::os::unix::prelude::PermissionsExt;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::{fs::File, io::Write};
Expand Down Expand Up @@ -199,16 +200,35 @@ impl InnerState {
extract(&zip_path, &folder)?;

// Delete zip
let _ = remove_file(zip_path);
let _ = remove_file(&zip_path);

// Change permissions (if on Linux)
if cfg!(target_os = "linux") {
let exec = self.get_yarg_exec(version_id, profile)?;

let mut perms = fs::metadata(&exec)
.map_err(|e| format!("Failed to get permissions of file.\n{:?}", e))?
.permissions();
perms.set_mode(0o7111);
fs::set_permissions(&exec, perms)
.map_err(|e| format!("Failed to set permissions of file.\n{:?}", e))?;
}

Ok(())
}

pub fn play_yarg(&self, version_id: String, profile: String) -> Result<(), String> {
fn get_yarg_exec(&self, version_id: String, profile: String) -> Result<PathBuf, String> {
let mut path = self.yarg_folder.join(profile).join(version_id);
path = match get_os().as_str() {
"windows" => path.join("YARG.exe"),
"linux" => path.join("YARG.x86_64"),
"linux" => {
// Stable uses "YARG.x86_64", and nightly uses "YARG"
let mut p = path.join("YARG.x86_64");
if !p.exists() {
p = path.join("YARG");
}
p
}
"macos" => path
.join("YARG.app")
.join("Contents")
Expand All @@ -217,6 +237,11 @@ impl InnerState {
_ => Err("Unknown platform for launch!")?,
};

Ok(path)
}

pub fn play_yarg(&self, version_id: String, profile: String) -> Result<(), String> {
let path = self.get_yarg_exec(version_id, profile)?;
Command::new(&path)
.spawn()
.map_err(|e| format!("Failed to start YARG. Is it installed?\n{:?}", e))?;
Expand Down

0 comments on commit 980fb2d

Please sign in to comment.