Add to_file() to VocFile

This commit is contained in:
Pedro de Oliveira 2022-11-13 05:08:00 +00:00
parent d6f620dfd8
commit 33484bfa97
1 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,6 @@
use std::fmt;
use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
use std::io::{Read, Seek, SeekFrom, Write};
#[derive(Clone, Copy, Debug)]
pub enum Codec {
@ -33,8 +33,7 @@ pub struct VocFile {
}
impl VocFile {
pub(crate) fn from_file(file_name: &str) -> Self {
println!("Parsing {} ...", file_name);
pub fn from_file(file_name: &str) -> Self {
let mut fp = File::open(file_name).unwrap();
// Signature - Creative Voice File
@ -184,6 +183,12 @@ impl VocFile {
result
}
pub fn to_file(&self, filename: &str) {
let mut fp = File::create(filename).unwrap();
drop(fp.write(&self.to_bytes()));
drop(fp.flush());
}
}
type BlockT = Box<dyn Block>;