better error handeling of tree
This commit is contained in:
parent
829e1deb6a
commit
1277870097
|
@ -1,6 +1,6 @@
|
|||
use eframe::egui;
|
||||
use egui::Color32;
|
||||
use std::{cmp::min, fs, io, path::Path, path::PathBuf};
|
||||
use std::{cmp::min, fs, io, path::Path, path::PathBuf, ffi::OsStr};
|
||||
|
||||
use crate::tools;
|
||||
use crate::Calcifer;
|
||||
|
@ -133,16 +133,17 @@ impl Calcifer {
|
|||
let name = path
|
||||
.file_name()
|
||||
.unwrap_or_else(|| OsStr::new(""))
|
||||
.to_string_lossy();
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
|
||||
if !path.is_dir() {
|
||||
if ui.button(name.to_string_lossy()).clicked() {
|
||||
if ui.button(name).clicked() {
|
||||
self.open_file(Some(path));
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
egui::CollapsingHeader::new(name.to_string_lossy()).show(ui, |ui| {
|
||||
egui::CollapsingHeader::new(name).show(ui, |ui| {
|
||||
match fs::read_dir(path) {
|
||||
Err(err) => {
|
||||
ui.label(format!("Error reading directory: {}", err));
|
||||
|
|
Loading…
Reference in a new issue