Skip to content

Commit

Permalink
cli, gui: Minor changes after cohae feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
Swyter committed Aug 18, 2023
1 parent 07ba086 commit f075c5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion eurochef/cli/src/filelist/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pub fn execute_command(
// Pad next data to 2048 bytes
let unaligned_pos = f_data.stream_position()?;
let aligned_pos = (unaligned_pos + 0x7ff) & !0x7ff; /* swy: 2048 - 1 = 0x7ff */
let difference: usize = (aligned_pos - unaligned_pos).try_into().unwrap();
let difference: usize = (aligned_pos - unaligned_pos) as usize;
println!(
"{} {} remaining space: {:#x} - {:#x} = {:#x}",
i, vpath, unaligned_pos, aligned_pos, difference
Expand Down
18 changes: 11 additions & 7 deletions eurochef/gui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl eframe::App for EurochefApp {

// swy: queue a load for the first drag-and-dropped file we encounter here;
// Rust seems like a very sane language, not verbose at all ¯\_(ツ)_/¯
ctx.input(|i: &egui::InputState| {
ctx.input(|i| {
if !i.raw.dropped_files.is_empty() {
for file in &i.raw.dropped_files {
let mut info = if let Some(path) = &file.path {
Expand All @@ -503,14 +503,18 @@ impl eframe::App for EurochefApp {
println!("Dragged the following file into the main window: {}", info);

// swy: put the path and its data inside load_input, load_clone is like a pointer
let mut f = File::open(&info).unwrap();
let mut data = vec![];
f.read_to_end(&mut data).unwrap();
match File::open(&info) {
Err(why) => println!("Couldn't read «{}», skipping: {}", info, why),
Ok(mut f) => {
let mut data = vec![];
f.read_to_end(&mut data).unwrap();

load_clone.store(Some((data, info.to_string())));
load_clone.store(Some((data, info)));

// swy: skip the rest, for the time being, we only care about the first one
break;
// swy: skip the rest, for the time being, we only care about the first one
break;
}
}
}
}
});
Expand Down

0 comments on commit f075c5f

Please sign in to comment.