Fix macOS
This commit is contained in:
parent
f20d3916fe
commit
eb79e560dc
|
|
@ -269,7 +269,7 @@ impl HubClient {
|
|||
path_response.context_menu(|ui| {
|
||||
if ui.button("Open directory").clicked() {
|
||||
use std::process::Command;
|
||||
Command::new("explorer")
|
||||
Command::new(rusty_hub::consts::FILE_MANAGER)
|
||||
.arg(&project.path)
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ pub struct Configuration {
|
|||
impl Configuration {
|
||||
pub fn rebuild(&mut self) {
|
||||
let paths = self.get_unity_paths();
|
||||
println!("{}",paths.len());
|
||||
self.editors_configurations = paths
|
||||
.into_iter()
|
||||
.parallel_map(|path| UnityEditor::new(&path))
|
||||
|
|
@ -35,6 +36,7 @@ impl Configuration {
|
|||
#[cfg(unix)]
|
||||
let uninstall_exists = true; // just check that on windows only
|
||||
let unity_exe_exists = entry.path().clone().join(consts::UNITY_EXE_NAME).exists();
|
||||
println!("PATH {} {:?}", unity_exe_exists, &entry.path().clone().join(consts::UNITY_EXE_NAME));
|
||||
|
||||
uninstall_exists && unity_exe_exists
|
||||
}
|
||||
|
|
@ -42,6 +44,7 @@ impl Configuration {
|
|||
fn search_for_editor(path: &str) -> Vec<String> {
|
||||
let path_exists = std::fs::metadata(path).is_ok();
|
||||
if !path_exists {
|
||||
println!("PATH NOT EXIST {}", &path);
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,3 +4,14 @@ pub const UNITY_EXE_NAME: &str = "Unity.exe";
|
|||
pub const UNITY_EXE_NAME: &str = "Unity.app/Contents/MacOS/Unity";
|
||||
#[cfg(target_os = "linux")]
|
||||
pub const UNITY_EXE_NAME: &str = "Unity";
|
||||
|
||||
#[cfg(windows)]
|
||||
pub const SLASH : &str = "\\";
|
||||
#[cfg(unix)]
|
||||
pub const SLASH : &str = "/";
|
||||
#[cfg(windows)]
|
||||
pub const FILE_MANAGER : &str = "explorer";
|
||||
#[cfg(target_os = "macos")]
|
||||
pub const FILE_MANAGER : &str = "open";
|
||||
#[cfg(target_os = "linux")]
|
||||
pub const FILE_MANAGER : &str = "xdg-open";
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
use exe::pe::VecPE;
|
||||
use exe::VSVersionInfo;
|
||||
|
||||
use std::borrow::Borrow;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
|
@ -24,16 +23,22 @@ impl UnityEditor {
|
|||
pub fn new(path: &str) -> Option<Self> {
|
||||
let base_path = Path::new(path);
|
||||
let exe_path = base_path.join(consts::UNITY_EXE_NAME);
|
||||
if !std::fs::metadata(&exe_path).is_ok() {
|
||||
let meta = std::fs::metadata(&exe_path);
|
||||
if !meta.is_ok() || !meta.unwrap().is_file() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut version :Option<String> = None;
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use exe::pe::VecPE;
|
||||
use exe::VSVersionInfo;
|
||||
let image = VecPE::from_disk_file(&exe_path).unwrap();
|
||||
let vs_version_check = VSVersionInfo::parse(&image);
|
||||
let vs_version_check = VSVersionInfo::parse(&image);
|
||||
if vs_version_check.is_err() {
|
||||
return None;
|
||||
}
|
||||
let mut version = None;
|
||||
if let Some(string_file_info) = vs_version_check.unwrap().string_file_info {
|
||||
let hashmap = string_file_info.children[0].string_map();
|
||||
if let Some(result_version) = hashmap.get("ProductVersion") {
|
||||
|
|
@ -42,18 +47,22 @@ impl UnityEditor {
|
|||
version = Some(short.to_string());
|
||||
}
|
||||
}
|
||||
}}
|
||||
if version.is_none() {
|
||||
let folder = base_path.to_str().expect("Fail").split(consts::SLASH).last().unwrap();
|
||||
version = Some(folder.to_string());
|
||||
}
|
||||
|
||||
if version.is_none() {
|
||||
None
|
||||
} else {
|
||||
Some(Self {
|
||||
version: version.unwrap().clone(),
|
||||
exe_path: exe_path.into_os_string().into_string().unwrap(),
|
||||
base_path: String::from(path),
|
||||
platforms: UnityEditor::get_platforms(path),
|
||||
})
|
||||
return None;
|
||||
}
|
||||
Some(Self {
|
||||
version: version.unwrap().clone(),
|
||||
exe_path: exe_path.into_os_string().into_string().unwrap(),
|
||||
base_path: String::from(path),
|
||||
platforms: UnityEditor::get_platforms(path),
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
fn get_platforms(unity_folder: &str) -> Vec<String> {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use std::{ops::Sub, path::Path, str};
|
||||
|
||||
use crate::consts;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct UnityProject {
|
||||
pub path: String,
|
||||
|
|
@ -61,7 +63,10 @@ impl UnityProject {
|
|||
}
|
||||
|
||||
pub fn try_get_project_at_path(path: &str) -> Option<UnityProject> {
|
||||
#[cfg(windows)]
|
||||
let path = path.trim_matches(char::from(0)).replace("/", "\\");
|
||||
#[cfg(unix)]
|
||||
let path = path.trim_matches(char::from(0));
|
||||
if !UnityProject::is_project_at_path(&path) {
|
||||
return None;
|
||||
}
|
||||
|
|
@ -77,7 +82,7 @@ impl UnityProject {
|
|||
|
||||
let mut project = UnityProject {
|
||||
path: path.to_string(),
|
||||
title: path.split("\\").last().unwrap().to_string(),
|
||||
title: path.split(consts::SLASH).last().unwrap().to_string(),
|
||||
version: project_version,
|
||||
branch: String::new(),
|
||||
is_valid: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue