Skip to content

Commit

Permalink
incorporate max rom size
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDavenport committed Apr 21, 2024
1 parent 50dfc14 commit 0619ce0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gamercade_fs/src/rom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{fs, io::Write, path::PathBuf};
use serde::{Deserialize, Serialize};

use gamercade_audio::SoundRom;
use gamercade_core::{FrameRate, GraphicsData, Resolution};
use gamercade_core::{FrameRate, GraphicsData, Resolution, MAX_ROM_SIZE};

use crate::{bundle, DataPack, EditorRom, GameAssetProvider, GameCodeProvider};

Expand Down Expand Up @@ -51,6 +51,15 @@ impl Rom {

match path.extension().and_then(|path| path.to_str()) {
Some("gcrom") => {
match file.metadata() {
Ok(metadata) => {
if metadata.len() > MAX_ROM_SIZE as u64 {
return Err(format!("File exceeds {MAX_ROM_SIZE} bytes."));
}
}
Err(e) => return Err(e.to_string()),
}

let reader = zstd::Decoder::new(file).map_err(|e| e.to_string())?;
bincode::deserialize_from::<_, Self>(reader).map_err(|e| e.to_string())
}
Expand Down

0 comments on commit 0619ce0

Please sign in to comment.