diff --git a/.gitignore b/.gitignore index 904edfa..37ecde4 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ yarn-debug.log* yarn-error.log* # moved lang files -/lang \ No newline at end of file +/lang +package-lock.json diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 5cced14..4479f86 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -712,14 +712,18 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" name = "cultivation" version = "0.1.0" dependencies = [ + "cc", "duct", + "file_diff", "futures-util", "http", "hudsucker", "is_elevated", + "libloading", "once_cell", "open 2.1.3", "rcgen", + "regex", "registry", "reqwest", "rustls-pemfile", @@ -979,6 +983,12 @@ dependencies = [ "rustc_version 0.3.3", ] +[[package]] +name = "file_diff" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31a7a908b8f32538a2143e59a6e4e2508988832d5d4d6f7c156b3cbc762643a5" + [[package]] name = "filetime" version = "0.2.17" @@ -1877,6 +1887,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libloading" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +dependencies = [ + "cfg-if 1.0.0", + "winapi", +] + [[package]] name = "line-wrap" version = "0.1.1" diff --git a/src-tauri/src/file_helpers.rs b/src-tauri/src/file_helpers.rs index 0f57d3e..eda3f6c 100644 --- a/src-tauri/src/file_helpers.rs +++ b/src-tauri/src/file_helpers.rs @@ -59,3 +59,33 @@ pub fn copy_file(path: String, new_path: String) -> bool { } } } + +#[tauri::command] +pub fn copy_file_with_new_name(path: String, new_path: String, new_name: String) -> bool { + let mut new_path_buf = std::path::PathBuf::from(&new_path); + + // If the new path doesn't exist, create it. + if !dir_exists(new_path_buf.pop().to_string().as_str()) { + std::fs::create_dir_all(&new_path).unwrap(); + } + + // Copy old to new + match std::fs::copy(&path, format!("{}/{}", new_path, new_name)) { + Ok(_) => true, + Err(e) => { + println!("Failed to copy file: {}", e); + false + } + } +} + +#[tauri::command] +pub fn delete_file(path: String) -> bool { + match std::fs::remove_file(path) { + Ok(_) => return true, + Err(e) => { + println!("Failed to delete file: {}", e); + return false + } + }; +} \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index f883512..8c317c7 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -40,9 +40,6 @@ fn main() { system_helpers::run_program, system_helpers::run_jar, system_helpers::open_in_browser, - system_helpers::copy_file, - system_helpers::copy_file_with_new_name, - system_helpers::delete_file, system_helpers::install_location, system_helpers::is_elevated, proxy::set_proxy_addr, @@ -53,6 +50,8 @@ fn main() { file_helpers::dir_is_empty, file_helpers::dir_delete, file_helpers::copy_file, + file_helpers::copy_file_with_new_name, + file_helpers::delete_file, file_helpers::are_files_identical, downloader::download_file, downloader::stop_download, diff --git a/src-tauri/src/system_helpers.rs b/src-tauri/src/system_helpers.rs index 4038840..a625b89 100644 --- a/src-tauri/src/system_helpers.rs +++ b/src-tauri/src/system_helpers.rs @@ -38,37 +38,6 @@ pub fn open_in_browser(url: String) { }; } - -#[tauri::command] -pub fn copy_file_with_new_name(path: String, new_path: String, new_name: String) -> bool { - let mut new_path_buf = std::path::PathBuf::from(&new_path); - - // If the new path doesn't exist, create it. - if !file_helpers::dir_exists(new_path_buf.pop().to_string().as_str()) { - std::fs::create_dir_all(&new_path).unwrap(); - } - - // Copy old to new - match std::fs::copy(&path, format!("{}/{}", new_path, new_name)) { - Ok(_) => true, - Err(e) => { - println!("Failed to copy file: {}", e); - false - } - } -} - -#[tauri::command] -pub fn delete_file(path: String) -> bool { - match std::fs::remove_file(path) { - Ok(_) => return true, - Err(e) => { - println!("Failed to delete file: {}", e); - return false - } - }; -} - #[tauri::command] pub fn install_location() -> String { let mut exe_path = std::env::current_exe().unwrap();