new files for crawler and model
This commit is contained in:
parent
620eadf1b8
commit
76ac38e4c1
16
src-tauri/src/impl/folder_crawler.rs
Normal file
16
src-tauri/src/impl/folder_crawler.rs
Normal file
@ -0,0 +1,16 @@
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
13
src-tauri/src/models/folder_data.rs
Normal file
13
src-tauri/src/models/folder_data.rs
Normal file
@ -0,0 +1,13 @@
|
||||
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