egui/eframe UI, clean up deps, remove Svelte/Tauri frontend
This commit is contained in:
parent
77c84ba3bd
commit
ff9a1b9b4a
37 changed files with 3982 additions and 2704 deletions
|
|
@ -1,23 +1,31 @@
|
|||
use crate::domain::file_entry::{EntryKind, FileEntry};
|
||||
use anyhow::Result;
|
||||
use std::fs;
|
||||
use crate::domain::file_entry::{FileEntry, EntryKind};
|
||||
|
||||
pub fn list(path: &str) -> Result<Vec<FileEntry>> {
|
||||
let mut entries: Vec<FileEntry> = fs::read_dir(path)?
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| {
|
||||
let meta = e.metadata().ok();
|
||||
let kind = meta.as_ref().map(|m| {
|
||||
if m.is_dir() { EntryKind::Dir }
|
||||
else if m.is_symlink() { EntryKind::Symlink }
|
||||
else { EntryKind::File }
|
||||
}).unwrap_or(EntryKind::File);
|
||||
let kind = meta
|
||||
.as_ref()
|
||||
.map(|m| {
|
||||
if m.is_dir() {
|
||||
EntryKind::Dir
|
||||
} else if m.is_symlink() {
|
||||
EntryKind::Symlink
|
||||
} else {
|
||||
EntryKind::File
|
||||
}
|
||||
})
|
||||
.unwrap_or(EntryKind::File);
|
||||
|
||||
let size = meta.as_ref().and_then(|m| {
|
||||
if m.is_file() { Some(m.len()) } else { None }
|
||||
});
|
||||
let size = meta
|
||||
.as_ref()
|
||||
.and_then(|m| if m.is_file() { Some(m.len()) } else { None });
|
||||
|
||||
let modified = meta.as_ref()
|
||||
let modified = meta
|
||||
.as_ref()
|
||||
.and_then(|m| m.modified().ok())
|
||||
.and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok())
|
||||
.map(|d| d.as_secs() as i64);
|
||||
|
|
@ -34,13 +42,11 @@ pub fn list(path: &str) -> Result<Vec<FileEntry>> {
|
|||
.collect();
|
||||
|
||||
// папки сначала, потом файлы, по имени
|
||||
entries.sort_by(|a, b| {
|
||||
match (&a.kind, &b.kind) {
|
||||
(EntryKind::Dir, EntryKind::Dir) => a.name.cmp(&b.name),
|
||||
(EntryKind::Dir, _) => std::cmp::Ordering::Less,
|
||||
(_, EntryKind::Dir) => std::cmp::Ordering::Greater,
|
||||
_ => a.name.cmp(&b.name),
|
||||
}
|
||||
entries.sort_by(|a, b| match (&a.kind, &b.kind) {
|
||||
(EntryKind::Dir, EntryKind::Dir) => a.name.cmp(&b.name),
|
||||
(EntryKind::Dir, _) => std::cmp::Ordering::Less,
|
||||
(_, EntryKind::Dir) => std::cmp::Ordering::Greater,
|
||||
_ => a.name.cmp(&b.name),
|
||||
});
|
||||
|
||||
Ok(entries)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue