Enhance file browsing and handling in main.rs
This commit provides additional functionality to the file manager, allowing users to view and open files within directories. The 'get_files' command has been added to the main.rs file. This new command navigates directories and retrieves relevant details including the metadata. The metadata includes the creation, modification, and access times converted into Unix time. To handle possible errors during these operations, proper error checks have been put in place. An existing error has been rectified in the tauri.conf.json file. File scopes have been extended to ensure all directories can be
This commit is contained in:
parent
e8969a4306
commit
d2f6d1640a
|
@ -60,6 +60,22 @@ fn get_files(
|
|||
}
|
||||
}
|
||||
|
||||
let mut created = 0 as u64;
|
||||
if let Ok(created_date) = metadata.created() {
|
||||
created = created_date.duration_since(UNIX_EPOCH).unwrap().as_secs();
|
||||
}
|
||||
|
||||
|
||||
let mut modified = 0 as u64;
|
||||
if let Ok(modified_date) = metadata.modified() {
|
||||
modified = modified_date.duration_since(UNIX_EPOCH).unwrap().as_secs();
|
||||
}
|
||||
|
||||
let mut accessed = 0 as u64;
|
||||
if let Ok(accessed_date) = metadata.accessed() {
|
||||
accessed = accessed_date.duration_since(UNIX_EPOCH).unwrap().as_secs();
|
||||
}
|
||||
|
||||
data.push(EntryMetaData{
|
||||
name: entry.file_name().to_string_lossy().to_string(),
|
||||
path: entry.path().to_string_lossy().to_string(),
|
||||
|
@ -69,9 +85,9 @@ fn get_files(
|
|||
is_symlink: metadata.is_symlink(),
|
||||
directory_item_count,
|
||||
permission,
|
||||
created: metadata.created().unwrap().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||
modified: metadata.modified().unwrap().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||
accessed: metadata.accessed().unwrap().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||
created,
|
||||
modified,
|
||||
accessed,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
"fs": {
|
||||
"all": true,
|
||||
"scope": [
|
||||
"/",
|
||||
"**",
|
||||
"$APP",
|
||||
"$APP/**",
|
||||
|
|
Loading…
Reference in New Issue