[thin_shrink] Add NoopVisitor
This commit is contained in:
parent
861b2f21ff
commit
3f1b776359
@ -26,7 +26,6 @@ fn main() {
|
||||
|
||||
// FIXME: check these look like xml
|
||||
let input_file = matches.value_of("INPUT").unwrap();
|
||||
let map_file = matches.value_of("MAP").unwrap();
|
||||
let output_file = matches.value_of("OUTPUT").unwrap();
|
||||
|
||||
if !file_utils::file_exists(input_file) {
|
||||
|
@ -6,14 +6,15 @@ use crate::shrink::xml;
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
pub fn shrink(input_file: &str, _output_file: &str, _map_file: &str) -> Result<()> {
|
||||
pub fn shrink(input_file: &str, _output_file: &str) -> Result<()> {
|
||||
let input = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(false)
|
||||
.custom_flags(libc::O_EXCL)
|
||||
.open(input_file)?;
|
||||
|
||||
let mut visitor = xml::XmlWriter::new(std::io::stdout());
|
||||
// let mut visitor = xml::XmlWriter::new(std::io::stdout());
|
||||
let mut visitor = xml::NoopVisitor::new();
|
||||
xml::read(input, &mut visitor)?;
|
||||
|
||||
Ok(())
|
||||
|
@ -51,6 +51,25 @@ pub trait MetadataVisitor {
|
||||
fn eof(&mut self) -> Result<()>;
|
||||
}
|
||||
|
||||
pub struct NoopVisitor {
|
||||
}
|
||||
|
||||
impl NoopVisitor {
|
||||
pub fn new() -> NoopVisitor { NoopVisitor {} }
|
||||
}
|
||||
|
||||
impl MetadataVisitor for NoopVisitor {
|
||||
fn superblock_b(&mut self, _sb: &Superblock) -> Result<()> {Ok(())}
|
||||
fn superblock_e(&mut self) -> Result<()> {Ok(())}
|
||||
|
||||
fn device_b(&mut self, _d: &Device) -> Result<()> {Ok(())}
|
||||
fn device_e(&mut self) -> Result<()> {Ok(())}
|
||||
|
||||
fn map(&mut self, _m: Map) -> Result<()> {Ok(())}
|
||||
|
||||
fn eof(&mut self) -> Result<()> {Ok(())}
|
||||
}
|
||||
|
||||
pub struct XmlWriter<W: Write> {
|
||||
w: Writer<W>,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user