load folders method
This commit is contained in:
parent
efc34c8909
commit
a153a2c521
7100
package-lock.json
generated
7100
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,16 +0,0 @@
|
|||||||
use models::folder_data::FolderData;
|
|
||||||
use std::fs;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
fn crawl(path: PathBuf) -> FolderData {
|
|
||||||
|
|
||||||
/*initialize mutable variables for tracking information about the folder.*/
|
|
||||||
let mut size = 0; // Total size of all the files and subfolders in the folder.
|
|
||||||
let mut subfolder_count = 0; // Total number of subfolders in the folder.
|
|
||||||
let mut file_count = 0; // Total number of files in the folder.
|
|
||||||
let mut children = Vec::new(); // Vector to store the child folder data
|
|
||||||
|
|
||||||
if let Ok(entries) = fs::read_dir(&path) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,6 +2,8 @@
|
|||||||
all(not(debug_assertions), target_os = "windows"),
|
all(not(debug_assertions), target_os = "windows"),
|
||||||
windows_subsystem = "windows"
|
windows_subsystem = "windows"
|
||||||
)]
|
)]
|
||||||
|
use std::path::PathBuf;
|
||||||
|
mod folder_crawler;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
@ -17,3 +19,12 @@ fn main() {
|
|||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application!");
|
.expect("error while running tauri application!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn load_folders(){
|
||||||
|
let root = PathBuf::from("C:/Users/Damie/Desktop");
|
||||||
|
let crawler = folder_crawler::FolderCrawler::new(root);
|
||||||
|
for folder_data in crawler {
|
||||||
|
println!("{:?}", folder_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
struct FolderData {
|
|
||||||
name: String,
|
|
||||||
path: String,
|
|
||||||
#[serde(rename = "type")]
|
|
||||||
folder_type: String, // Always "folder" in this case
|
|
||||||
size: u64,
|
|
||||||
subfolders: usize,
|
|
||||||
children: Vec<FolderData>,
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user