From c9342fe438da4dfc55c264344ca21690df337a35 Mon Sep 17 00:00:00 2001 From: Anish K Date: Mon, 13 Jan 2025 21:51:55 -0500 Subject: [PATCH] Minor changes --- src/package_manager.rs | 2 ++ src/utils.rs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/package_manager.rs b/src/package_manager.rs index 7cb88f2..d515588 100644 --- a/src/package_manager.rs +++ b/src/package_manager.rs @@ -1,6 +1,7 @@ use crate::config::{self, Config, Dependnecy}; use crate::constants::{CONFIG_FILE, PACKAGE_CONFIG_FILE, PACKAGE_DIR}; use crate::kiln_package::{self, KilnPackageConfig}; +use crate::utils; use std::collections::HashSet; use std::env; use std::ffi::OsStr; @@ -588,6 +589,7 @@ fn copy_deps_global_to_local(pkg: &Package, dep_type: DepType) -> Result<(), Pkg } dbg!(&global_p); + fs::copy(global_p, new_p)?; } } diff --git a/src/utils.rs b/src/utils.rs index 5217b42..c12c395 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -149,6 +149,7 @@ pub fn expand_user(path: &str) -> String { } /// Prints a warning message in a standardized way +/// This is used to print warnings related to static analysis pub fn print_warning( warning_source: &str, filename: &str, @@ -167,3 +168,22 @@ pub fn print_warning( ); println!("{}\n", err_msg); } + + +pub(super) fn create_symlink>(src_file: T, dst_link: T) -> Result<(), std::io::Error> { + #[cfg(target_family = "unix")] + { + std::os::unix::fs::symlink(src_file, dst_link)?; + } + #[cfg(target_family = "windows")] + { + if original.is_file() { + std::os::windows::fs::symlink_file(src_file, dst_link) + } else if original.is_dir() { + std::os::windows::fs::symlink_dir(src_file, dst_link) + } else { + Err(io::Error::new(io::ErrorKind::Other, "Original path is neither a file nor a directory.")) + } + } + Ok(()) +} \ No newline at end of file