diff --git a/Cargo.lock b/Cargo.lock index bbf24d3..c0df657 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -616,7 +616,7 @@ dependencies = [ [[package]] name = "egui-file-dialog" version = "0.7.0" -source = "git+https://github.com/crumblingstatue/egui-file-dialog.git?branch=active-entry#5f313b386b423b3ba4350b0ced44566a36e6fc16" +source = "git+https://github.com/crumblingstatue/egui-file-dialog.git?branch=hexerator#25299058a9b827579848eb24278d8b9cc7d2493d" dependencies = [ "directories", "egui", diff --git a/Cargo.toml b/Cargo.toml index a1b8959..9a8fe6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ parking_lot = "0.12.1" egui_code_editor = "0.2.10" # luajit breaks with panic=abort, because it relies on unwinding for exception handling mlua = { version = "0.9.7", features = ["lua54", "vendored"] } -egui-file-dialog = { git = "https://github.com/crumblingstatue/egui-file-dialog.git", branch = "active-entry" } +egui-file-dialog = { git = "https://github.com/crumblingstatue/egui-file-dialog.git", branch = "hexerator" } human_bytes = "0.4.3" shlex = "1.3.0" smart-default = "0.7.1" diff --git a/src/gui/file_ops.rs b/src/gui/file_ops.rs index dcc9bf4..8cc5d8a 100644 --- a/src/gui/file_ops.rs +++ b/src/gui/file_ops.rs @@ -15,7 +15,6 @@ use { anyhow::Context as _, egui_file_dialog::FileDialog, std::{ - fs::OpenOptions, io::Write as _, path::{Path, PathBuf}, }, @@ -30,6 +29,7 @@ pub struct FileOps { pub dialog: FileDialog, pub op: Option, preview_cache: PathCache, + file_dialog_source_args: SourceArgs, } impl Default for FileOps { @@ -40,6 +40,7 @@ impl Default for FileOps { .allow_path_edit_to_save_file_without_extension(true), op: Default::default(), preview_cache: PathCache::default(), + file_dialog_source_args: SourceArgs::default(), } } } @@ -127,6 +128,9 @@ impl FileOps { if ft.is_symlink() { ui.label("Symbolic link"); } + if !(ft.is_file() || ft.is_dir()) { + ui.label(format!("Special (size: {})", meta.len())); + } } Err(e) => { ui.label(e.to_string()); @@ -140,6 +144,9 @@ impl FileOps { } else { ui.heading("Hexerator"); } + ui.separator(); + ui.checkbox(&mut self.file_dialog_source_args.stream, "stream"); + ui.checkbox(&mut self.file_dialog_source_args.read_only, "read-only"); }); if let Some(path) = self.dialog.take_selected() && let Some(op) = self.op.take() @@ -159,9 +166,15 @@ impl FileOps { advanced_open_window.path_to_meta = Some(path); } FileOp::LoadFile => { - let write = OpenOptions::new().write(true).open(&path).is_ok(); + self.file_dialog_source_args.file = Some(path); msg_if_fail( - app.load_file(path, !write, msg, font_size, line_spacing), + app.load_file_args( + self.file_dialog_source_args.clone(), + None, + msg, + font_size, + line_spacing, + ), "Failed to load file (read-write)", msg, );