[UNIX] Add full compatibility
This commit is contained in:
parent
3e9f4470c0
commit
eaf11680da
1 changed files with 16 additions and 7 deletions
|
@ -1,12 +1,15 @@
|
||||||
use std::env::consts;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::fs;
|
use std::fs::{self, Metadata};
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
use std::os::unix::fs::symlink;
|
use std::os::unix::fs::symlink;
|
||||||
|
|
||||||
fn file_is_executable(path: &PathBuf) -> bool {
|
#[cfg(target_family = "unix")]
|
||||||
if consts::FAMILY == "windows" {
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
|
fn file_is_executable(path: &PathBuf, metadata: &Metadata) -> bool {
|
||||||
|
#[cfg(target_family = "windows")]
|
||||||
|
{
|
||||||
match path.extension() {
|
match path.extension() {
|
||||||
Some(ext) => {
|
Some(ext) => {
|
||||||
let extension = match ext.to_str() {
|
let extension = match ext.to_str() {
|
||||||
|
@ -20,8 +23,14 @@ fn file_is_executable(path: &PathBuf) -> bool {
|
||||||
},
|
},
|
||||||
None => false
|
None => false
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
todo!()
|
#[cfg(target_family = "unix")]
|
||||||
|
{
|
||||||
|
if metadata.permissions().mode() & 0o111 != 0 {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +41,7 @@ fn get_binary_files(install_package_folder: &PathBuf) -> Result<Vec<PathBuf>, St
|
||||||
for path_result in paths {
|
for path_result in paths {
|
||||||
let path = path_result.map_err(|_| format!("Failed to get file"))?;
|
let path = path_result.map_err(|_| format!("Failed to get file"))?;
|
||||||
let metadata = path.metadata().map_err(|_| format!("Failed to get metadata"))?;
|
let metadata = path.metadata().map_err(|_| format!("Failed to get metadata"))?;
|
||||||
if metadata.is_file() && file_is_executable(&path.path()) {
|
if metadata.is_file() && file_is_executable(&path.path(), &metadata) {
|
||||||
files.push(path.path().clone());
|
files.push(path.path().clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue