move image files to local bg folder

This commit is contained in:
SpikeHD
2022-06-01 18:08:50 -07:00
parent da6d05c7d0
commit 53f42be967
4 changed files with 45 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ use std::thread;
use std::process::Command;
use tauri;
use open;
use crate::system_helpers;
#[tauri::command]
pub fn run_program(path: String) {
@@ -55,6 +56,26 @@ pub fn open_in_browser(url: String) {
};
}
#[tauri::command]
pub fn get_local_bg_path() -> String {
// Get the local BG folder.
return format!("{}/bg", system_helpers::install_location())
}
#[tauri::command]
pub fn copy_file(path: String, new_path: String) -> bool {
let filename = &path.split("/").last().unwrap();
// Copy old to new
match std::fs::copy(&path, format!("{}/{}", new_path, filename)) {
Ok(_) => true,
Err(e) => {
println!("Failed to copy file: {}", e);
false
}
}
}
pub fn install_location() -> String {
let mut exe_path = std::env::current_exe().unwrap();