on the way to a usable version
This commit is contained in:
+16
-4
@@ -1,13 +1,25 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::reader::AheadReader;
|
||||
|
||||
use std::io::BufReader;
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{self, Read, Write},
|
||||
io::{self, Write},
|
||||
};
|
||||
|
||||
pub(crate) fn read_from_file_or_stdin<S: AsRef<str>>(input_file: Option<S>) -> Box<dyn Read> {
|
||||
pub const BUFSIZE: usize = 64 * 1024; // 64 KiB
|
||||
|
||||
pub(crate) fn read_from_file_or_stdin<S: AsRef<str>>(
|
||||
input_file: Option<S>,
|
||||
bufsz: usize,
|
||||
) -> AheadReader {
|
||||
match input_file {
|
||||
Some(f) => Box::new(File::open(f.as_ref()).unwrap()),
|
||||
None => Box::new(io::stdin()),
|
||||
Some(f) => AheadReader::from(
|
||||
Box::new(BufReader::new(File::open(f.as_ref()).unwrap())),
|
||||
bufsz,
|
||||
),
|
||||
None => AheadReader::from(Box::new(io::stdin().lock()), bufsz),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user