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