mirror of
https://github.com/iluvcapra/bwavfile.git
synced 2025-12-31 17:00:44 +00:00
Added buffered IO
And updated tests to reflect this
This commit is contained in:
@@ -13,7 +13,7 @@ use super::chunks::ReadBWaveChunks;
|
||||
use super::cue::Cue;
|
||||
|
||||
use std::io::Cursor;
|
||||
use std::io::{Read, Seek};
|
||||
use std::io::{Read, Seek, BufReader};
|
||||
|
||||
|
||||
|
||||
@@ -68,13 +68,22 @@ pub struct WaveReader<R: Read + Seek> {
|
||||
pub inner: R,
|
||||
}
|
||||
|
||||
impl WaveReader<BufReader<File>> {
|
||||
|
||||
pub fn open(path: &str) -> Result<Self, ParserError> {
|
||||
let f = File::open(path)?;
|
||||
let inner = BufReader::new(f);
|
||||
Ok( Self::new(inner)? )
|
||||
}
|
||||
}
|
||||
|
||||
impl WaveReader<File> {
|
||||
|
||||
/// Open a file for reading.
|
||||
/// Open a file for reading with unbuffered IO.
|
||||
///
|
||||
/// A convenience that opens `path` and calls `Self::new()`
|
||||
|
||||
pub fn open(path: &str) -> Result<Self, ParserError> {
|
||||
pub fn open_unbuffered(path: &str) -> Result<Self, ParserError> {
|
||||
let inner = File::open(path)?;
|
||||
return Ok( Self::new(inner)? )
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user