load folders method

This commit is contained in:
Damien 2025-02-22 08:36:14 -05:00
parent efc34c8909
commit a153a2c521
4 changed files with 6966 additions and 174 deletions

7100
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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) {
}
}

View File

@ -2,6 +2,8 @@
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use std::path::PathBuf;
mod folder_crawler;
fn main() {
tauri::Builder::default()
@ -17,3 +19,12 @@ fn main() {
.run(tauri::generate_context!())
.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);
}
}

View File

@ -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>,
}