gonna make a reader
parent
384681329a
commit
4bbb4fe3f8
58
src/lib.rs
58
src/lib.rs
|
@ -66,36 +66,36 @@ pub fn parse(file: std::fs::File) -> Result<()> {
|
|||
let mut forwards = false;
|
||||
let mut state = State::Start;
|
||||
|
||||
reader.;
|
||||
// reader.;
|
||||
|
||||
while let Ok(Some(line)) = if forwards {
|
||||
reader.next_line()
|
||||
} else {
|
||||
reader.prev_line()
|
||||
} {
|
||||
match state {
|
||||
State::Start => {
|
||||
if line.contains("%%EOF") {
|
||||
state = State::FoundEof;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
State::FoundEof => {
|
||||
if line.contains("startxref") {
|
||||
state = State::FoundStartXref;
|
||||
forwards = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
State::FoundStartXref => {
|
||||
state = State::FoundXrefOffset;
|
||||
offset_to_trailer = line.parse::<u64>()?;
|
||||
}
|
||||
State::FoundXrefOffset => {
|
||||
reader.seek();
|
||||
}
|
||||
}
|
||||
}
|
||||
// while let Ok(Some(line)) = if forwards {
|
||||
// reader.next_line()
|
||||
// } else {
|
||||
// reader.prev_line()
|
||||
// } {
|
||||
// match state {
|
||||
// State::Start => {
|
||||
// if line.contains("%%EOF") {
|
||||
// state = State::FoundEof;
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// State::FoundEof => {
|
||||
// if line.contains("startxref") {
|
||||
// state = State::FoundStartXref;
|
||||
// forwards = true;
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// State::FoundStartXref => {
|
||||
// state = State::FoundXrefOffset;
|
||||
// offset_to_trailer = line.parse::<u64>()?;
|
||||
// }
|
||||
// State::FoundXrefOffset => {
|
||||
// reader.seek();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue