mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-15 00:47:08 +00:00
IFF: Subtract header from file length
This commit is contained in:
parent
10b8462e7a
commit
464e78e222
3 changed files with 8 additions and 7 deletions
|
@ -4,19 +4,20 @@ use crate::iff::chunk::Chunks;
|
|||
use std::fs::File;
|
||||
use std::io::{Read, Seek, SeekFrom, Write};
|
||||
|
||||
use byteorder::{ByteOrder, ReadBytesExt, WriteBytesExt};
|
||||
use byteorder::{ByteOrder, WriteBytesExt};
|
||||
|
||||
pub(in crate::id3::v2) fn write_to_chunk_file<B>(data: &mut File, tag: &[u8]) -> Result<()>
|
||||
where
|
||||
B: ByteOrder,
|
||||
{
|
||||
data.seek(SeekFrom::Current(4))?;
|
||||
let file_size = data.read_u32::<B>()?;
|
||||
data.seek(SeekFrom::Current(4))?;
|
||||
// RIFF....WAVE
|
||||
data.seek(SeekFrom::Current(12))?;
|
||||
|
||||
let file_len = data.metadata()?.len().saturating_sub(12);
|
||||
|
||||
let mut id3v2_chunk = (None, None);
|
||||
|
||||
let mut chunks = Chunks::<B>::new(u64::from(file_size)); // TODO
|
||||
let mut chunks = Chunks::<B>::new(file_len);
|
||||
|
||||
while chunks.next(data).is_ok() {
|
||||
if &chunks.fourcc == b"ID3 " || &chunks.fourcc == b"id3 " {
|
||||
|
|
|
@ -358,7 +358,7 @@ where
|
|||
|
||||
fn write_to_inner(data: &mut File, mut tag: AiffTextChunksRef<'_, T, AI>) -> Result<()> {
|
||||
super::read::verify_aiff(data)?;
|
||||
let file_len = data.metadata()?.len();
|
||||
let file_len = data.metadata()?.len().saturating_sub(12);
|
||||
|
||||
let text_chunks = Self::create_text_chunks(&mut tag)?;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ where
|
|||
I: Iterator<Item = (&'a str, &'a str)>,
|
||||
{
|
||||
verify_wav(data)?;
|
||||
let file_len = data.metadata()?.len();
|
||||
let file_len = data.metadata()?.len().saturating_sub(12);
|
||||
|
||||
let mut riff_info_bytes = Vec::new();
|
||||
create_riff_info(&mut tag.items, &mut riff_info_bytes)?;
|
||||
|
|
Loading…
Reference in a new issue