Skip to content

Commit

Permalink
acknowledge review points
Browse files Browse the repository at this point in the history
  • Loading branch information
ieee802dot11ac committed Jan 15, 2024
1 parent ff8d9f2 commit 5dfe7a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 30 deletions.
1 change: 1 addition & 0 deletions crates/milo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "milo"
version = "0.1.0"
edition = "2021"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
8 changes: 5 additions & 3 deletions crates/milo/src/ark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ pub mod amp;
pub mod freq;

pub enum ArkTypes {
Empty,
FreqArk(freq::FreqArchive),
AmpArk(amp::AmpArchive),
}

pub fn load_ark_file(f: &mut File) -> Result<ArkTypes, Box<dyn Error>> {
let vercheck = read_u32(f, true)?;
let mut ark: ArkTypes = ArkTypes::Empty;
let ark: ArkTypes;
match vercheck {
0x004B5241 => {
let mut freq = freq::FreqArchive::new();
Expand All @@ -26,7 +25,10 @@ pub fn load_ark_file(f: &mut File) -> Result<ArkTypes, Box<dyn Error>> {
amp.load(f, 0)?;
ark = ArkTypes::AmpArk(amp);
}
_ => println!("unrecognized ark version. if gh1 or later, use the .hdr and not the .ark")
_ => {
println!("unrecognized ark version. if gh1 or later, use the .hdr and not the .ark");
return Err::<_, Box<dyn Error>>("unkver".into());
}
}
Ok(ark)
}
29 changes: 2 additions & 27 deletions crates/milo/src/ark/amp.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt::{Formatter, Display};
use std::error::Error;

use crate::traits::Load;
use crate::fio;
Expand Down Expand Up @@ -72,7 +73,7 @@ impl AmpArchive {
}

impl Load for AmpArchive {
fn load(&mut self, f: &mut std::fs::File, _: u32) -> Result<(), Box<dyn std::error::Error>> {
fn load(&mut self, f: &mut std::fs::File, _: u32) -> Result<(), Box<dyn Error>> {
self.version = fio::read_u32(f, true)?;
self.entry_ct = fio::read_u32(f, true)?;
for _ in 0..self.entry_ct {
Expand Down Expand Up @@ -113,29 +114,3 @@ impl Display for AmpArchive {
Ok(())
}
}

impl Clone for AmpArchive {
fn clone(&self) -> Self {
let mut new_entries: Vec<AmpFileEntry> = vec![];
for entry in &self.entries {
new_entries.push(*entry);
}
let mut new_strtbl: Vec<String> = vec![];
for string in &self.string_table {
new_strtbl.push(string.clone());
}
let mut new_stridxs: Vec<u32> = vec![];
for idx in &self.string_idx_entries {
new_stridxs.push(*idx);
}
Self {
version: self.version,
entry_ct: self.entry_ct,
entries: new_entries,
str_table_size: self.str_table_size,
string_table: new_strtbl,
string_idx_count: self.string_idx_count,
string_idx_entries: new_stridxs
}
}
}

0 comments on commit 5dfe7a7

Please sign in to comment.