From d5aa53fafed0dbf6d43943e3b88b99693821e5cd Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 23 Mar 2025 20:18:10 +0100 Subject: audio clips --- src/classes/streaminginfo.rs | 52 -------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 src/classes/streaminginfo.rs (limited to 'src/classes/streaminginfo.rs') diff --git a/src/classes/streaminginfo.rs b/src/classes/streaminginfo.rs deleted file mode 100644 index d593a5b..0000000 --- a/src/classes/streaminginfo.rs +++ /dev/null @@ -1,52 +0,0 @@ -use std::io::{Read, Seek, SeekFrom}; - -use crate::{ - object::{Value, parser::FromValue}, - unityfs::UnityFS, -}; -use anyhow::{Result, anyhow, bail}; -use serde::Serialize; - -#[derive(Debug, Serialize)] -pub struct StreamingInfo { - pub offset: u64, - pub path: String, - pub size: u32, -} - -impl FromValue for StreamingInfo { - fn from_value(v: Value) -> Result { - let mut fields = v.as_class("StreamingInfo")?; - Ok(StreamingInfo { - offset: fields.field("offset")?, - size: fields.field("size")?, - path: fields.field("path")?, - }) - } -} - -impl StreamingInfo { - pub fn read(&self, fs: &UnityFS) -> Result> { - if !self.path.starts_with("archive:") { - bail!( - "StreamingInfo path does not start on 'archive:' ({:?})", - self.path - ) - } - let nodeinfo = fs - .header - .nodes() - .iter() - .find(|n| self.path.ends_with(&n.name)) - .ok_or(anyhow!("node with path {:?} not found", self.path))? - .to_owned(); - - let mut buf = Vec::new(); - - let mut node = fs.read(&nodeinfo)?; - node.seek(SeekFrom::Start(self.offset))?; - node.take(self.size as u64).read_to_end(&mut buf)?; - - Ok(buf) - } -} -- cgit v1.2.3-70-g09d2