Skip to content

Commit

Permalink
Added BIOS file validation
Browse files Browse the repository at this point in the history
  • Loading branch information
integralfx authored Nov 16, 2018
1 parent f82d1f0 commit 657933e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
8 changes: 4 additions & 4 deletions src/TimingsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ private static void print_timings(ATOM_VRAM_TIMING_ENTRY e)
System.out.print(String.format("0x%02X ", b));
}

public TimingsEditor(String bios_file)
public TimingsEditor(String bios_file) throws IllegalArgumentException
{
Path path = Paths.get(bios_file);
try
{
bios_bytes = Files.readAllBytes(path);
if(!init())
throw new Exception("invalid BIOS file");
throw new IllegalArgumentException("Invalid BIOS file");
}
catch(Exception e)
catch(IOException e)
{
System.err.println("exception caught: " + e.getMessage());
System.err.println("failed to read " + bios_file);
e.printStackTrace();
}
}
Expand Down
52 changes: 29 additions & 23 deletions src/TimingsEditorGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,41 @@ public void actionPerformed(ActionEvent e)
{
if(fc.showOpenDialog(main_panel) == JFileChooser.APPROVE_OPTION)
{
File file = fc.getSelectedFile();
try {
File file = fc.getSelectedFile();

lbl_file.setText(file.getName());
timings_editor = new TimingsEditor(file.getAbsolutePath());
timings = timings_editor.get_timings();

timings_editor = new TimingsEditor(file.getAbsolutePath());
timings = timings_editor.get_timings();
lbl_file.setText(file.getName());

SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
SwingUtilities.invokeLater(new Runnable()
{
if(panel_timings != null)
@Override
public void run()
{
main_panel.remove(panel_timings);
panel_timings = null;
if(panel_timings != null)
{
main_panel.remove(panel_timings);
panel_timings = null;
}

if(panel_indices == null)
add_indices_panel();

add_timings_panel(timings.get(0).ucIndex);
revalidate();
repaint();
pack();

update_indices_cbox();
}

if(panel_indices == null)
add_indices_panel();

add_timings_panel(timings.get(0).ucIndex);
revalidate();
repaint();
pack();

update_indices_cbox();
}
});
});
}
catch(IllegalArgumentException ex)
{
show_error_dialog(ex.getMessage());
}
}
}
else if(e.getSource() == menu_item_saveas)
Expand Down

0 comments on commit 657933e

Please sign in to comment.