Rework reading from device and clean up.

This commit is contained in:
Olivia Brooks
2025-12-29 11:02:13 -05:00
parent 824d01be95
commit e08e2a0017
10 changed files with 628 additions and 536 deletions

15
src/io.rs Normal file
View File

@@ -0,0 +1,15 @@
use std::io::{self, Seek, SeekFrom};
/// Get length of data stream.
/// Physical length of data stream in bytes
/// (multiple of sector_size, rather than actual).
///
/// This will attempt to return the stream to its current read position.
pub fn get_stream_length<S: Seek>(stream: &mut S) -> io::Result<u64> {
let pos = stream.stream_position()?;
let len = stream.seek(SeekFrom::End(0));
stream.seek(SeekFrom::Start(pos))?;
len
}