get_rootfile() simplified
This commit is contained in:
parent
8b38cee7b8
commit
da77983228
2 changed files with 11 additions and 12 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -396,7 +396,7 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pbdbfixer"
|
name = "pbdbfixer"
|
||||||
version = "0.8.3"
|
version = "0.9.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
|
|
21
src/epub.rs
21
src/epub.rs
|
@ -61,18 +61,17 @@ fn get_rootfile(archive: &mut ZipArchive<File>) -> String {
|
||||||
loop {
|
loop {
|
||||||
match reader.read_event_into(&mut buf) {
|
match reader.read_event_into(&mut buf) {
|
||||||
Ok(Event::Start(ref e)) | Ok(Event::Empty(ref e))
|
Ok(Event::Start(ref e)) | Ok(Event::Empty(ref e))
|
||||||
if e.local_name().into_inner() == b"rootfile" =>
|
if e.name().as_ref() == b"rootfile" =>
|
||||||
{
|
{
|
||||||
opf_filename = String::from_utf8(
|
opf_filename = e
|
||||||
e.attributes()
|
.attributes()
|
||||||
.filter(|attr| attr.as_ref().unwrap().key.into_inner() == b"full-path")
|
.filter(|attr| attr.as_ref().unwrap().key.as_ref() == b"full-path")
|
||||||
.next()
|
.next()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.value
|
.unescape_value()
|
||||||
.to_vec(),
|
.unwrap()
|
||||||
)
|
.to_string();
|
||||||
.unwrap();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ok(Event::Eof) => break,
|
Ok(Event::Eof) => break,
|
||||||
|
|
Loading…
Reference in a new issue