From 824fccecd3875c36da8cbc414445bf8241e23ad3 Mon Sep 17 00:00:00 2001 From: "Florian RICHER (MrDev023)" Date: Mon, 9 Aug 2021 22:44:15 +0200 Subject: [PATCH] [Windows] Replace symlink by .bat Windows can't run executable file from symlink so it's necessary to create .bat to run in folder --- src/installer/utils/file_utils/binary_utils.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/installer/utils/file_utils/binary_utils.rs b/src/installer/utils/file_utils/binary_utils.rs index ca26652..bd4d1ec 100644 --- a/src/installer/utils/file_utils/binary_utils.rs +++ b/src/installer/utils/file_utils/binary_utils.rs @@ -2,9 +2,6 @@ use std::env::consts; use std::path::PathBuf; use std::fs; -#[cfg(target_os = "windows")] -use std::os::windows::fs::symlink_file; - fn file_is_executable(path: &PathBuf) -> bool { if consts::FAMILY == "windows" { match path.extension() { @@ -49,7 +46,13 @@ pub fn create_symlink_of_binary_files(install_package_folder: &PathBuf, binary_p let output_path = binary_package_folder.join(file.file_name().ok_or(format!("Failed to get filename"))?); #[cfg(target_os = "windows")] - symlink_file(file.as_os_str(), output_path.as_os_str()).map_err(|_| format!("Failed to create symlink"))?; + { + let file_path = file.as_os_str().to_str().ok_or(format!("Failed to get filename str"))?; + fs::write(output_path, format!(" + @echo off + {} %* + ", file_path)).map_err(|_| format!("Failed to create symlink"))?; + } } Ok(())