Skip to content

Commit

Permalink
Merge pull request #51 from RickyDane/feature/move_to_option
Browse files Browse the repository at this point in the history
Feature/move to option
  • Loading branch information
RickyDane committed Feb 21, 2024
2 parents 107995f + 0782019 commit 98b8e6e
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 48 deletions.
3 changes: 0 additions & 3 deletions src-tauri/build_1.rs

This file was deleted.

21 changes: 14 additions & 7 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,13 +638,17 @@ async fn search_for(mut file_name: String, max_items: i32, search_depth: i32, fi
}

#[tauri::command]
async fn copy_paste(app_window: Window, act_file_name: String, from_path: String, is_for_dual_pane: String) {
async fn copy_paste(app_window: Window, act_file_name: String, from_path: String, is_for_dual_pane: String, mut copy_to_path: String) {
if &copy_to_path.len() == &0 {
wng_log("No destination path provided. Defaulting to current dir".into());
copy_to_path = current_dir().unwrap().to_string_lossy().to_string();
}
unsafe {
COPY_COUNTER = 0.0;
}
let _ = &app_window.eval("document.querySelector('.progress-bar-container-popup').style.display = 'flex'");
dbg_log(format!("Copying: {} ...", &act_file_name));
let final_filename = get_final_filename(act_file_name, from_path.clone(), is_for_dual_pane).await;
let final_filename = get_final_filename(act_file_name, from_path.clone(), is_for_dual_pane, copy_to_path).await;

unsafe {
TO_COPY_COUNTER = count_entries(&from_path);
Expand All @@ -662,7 +666,11 @@ async fn copy_paste(app_window: Window, act_file_name: String, from_path: String
}

#[tauri::command]
async fn arr_copy_paste(app_window: Window, arr_items: Vec<String>, is_for_dual_pane: String) {
async fn arr_copy_paste(app_window: Window, arr_items: Vec<String>, is_for_dual_pane: String, mut copy_to_path: String) {
if &copy_to_path.len() == &0 {
wng_log("No destination path provided. Defaulting to current dir".into());
copy_to_path = current_dir().unwrap().to_string_lossy().to_string();
}
unsafe {
COPY_COUNTER = 0.0;
TO_COPY_COUNTER = 0.0
Expand All @@ -678,15 +686,15 @@ async fn arr_copy_paste(app_window: Window, arr_items: Vec<String>, is_for_dual_
let sw = Stopwatch::start_new();
for item_path in arr_items {
filename = item_path.replace("\\", "/").split("/").last().unwrap().to_string();
let final_filename = get_final_filename(filename, item_path.clone(), is_for_dual_pane.clone()).await;
let final_filename = get_final_filename(filename, item_path.clone(), is_for_dual_pane.clone(), copy_to_path.clone()).await;
// Execute the copy process for either a dir or file
copy_to(&app_window, final_filename, item_path);
}
dbg_log(format!("Copy-Paste time: {:?}", sw.elapsed()));
}

#[tauri::command]
async fn get_final_filename(act_file_name: String, from_path: String, is_for_dual_pane: String) -> String {
async fn get_final_filename(act_file_name: String, from_path: String, is_for_dual_pane: String, copy_to_path: String) -> String {
let file = fs::metadata(&from_path);
if &file.is_ok() != &true {
err_log("File could not be copied".into());
Expand All @@ -697,8 +705,7 @@ async fn get_final_filename(act_file_name: String, from_path: String, is_for_dua
file_name = act_file_name;
}
else {
file_name = current_dir()
.unwrap()
file_name = PathBuf::from(copy_to_path)
.join(&act_file_name)
.to_str()
.unwrap()
Expand Down
3 changes: 2 additions & 1 deletion ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ <h5 class="directory-entries-count"></h5>
<button class="context-item">Compress<i class="fa-solid fa-box"></i></button>
<button class="context-item">Copy<i class="fa-solid fa-copy"></i></button>
<button class="context-item" onclick="pasteItem()">Paste<i class="fa-solid fa-paste"></i></button>
<button class="context-item">Move to<i class="fa-solid fa-arrow-right"></i></button>
<button class="context-item">New file<i class="fa-solid fa-file"></i></button>
<button class="context-item">New folder<i class="fa-solid fa-folder-plus"></i></button>
<button class="context-item" onclick="createFolderInputPrompt()">New folder<i class="fa-solid fa-folder-plus"></i></button>
<button class="context-item">Rename<i class="fa-solid fa-file-signature"></i></button>
<button class="context-item">Properties<i class="fa-solid fa-info-circle"></i></button>
<button class="context-item context-open-in-terminal" onclick="openInTerminal()">Open in Terminal<i class="fa-solid fa-terminal"></i></button>
Expand Down
Loading

0 comments on commit 98b8e6e

Please sign in to comment.