aboutsummaryrefslogtreecommitdiffstats
path: root/src/epub.rs
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2020-05-17 01:39:32 -0700
committerJames Campos <james.r.campos@gmail.com>2020-05-17 01:39:32 -0700
commitd7ce4bdadb10ea4e70f8e48e2ddb990cf3087c49 (patch)
tree473f23c02995a5acd4269c4ee51cf24e40ab4c18 /src/epub.rs
parent885e0971f7af0fa445cb29f9c92ed03abbec2ecb (diff)
downloadbk-d7ce4bdadb10ea4e70f8e48e2ddb990cf3087c49.tar.gz
windows
Diffstat (limited to 'src/epub.rs')
-rw-r--r--src/epub.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/epub.rs b/src/epub.rs
index 4758a24..fa5f33f 100644
--- a/src/epub.rs
+++ b/src/epub.rs
@@ -97,7 +97,11 @@ impl Epub {
let xml = self.get_text(path);
let doc = Document::parse(&xml).unwrap();
- let rootdir = std::path::Path::new(&path).parent().unwrap();
+ // zip expects unix path even on windows
+ let rootdir = match path.rfind('/') {
+ Some(n) => &path[..n+1],
+ None => "",
+ };
let mut manifest = HashMap::new();
doc.root_element()
@@ -122,7 +126,7 @@ impl Epub {
.unwrap()
.attribute("href")
.unwrap();
- let xml = self.get_text(rootdir.join(path).to_str().unwrap());
+ let xml = self.get_text(&format!("{}{}", rootdir, path));
let doc = Document::parse(&xml).unwrap();
doc.descendants()
@@ -141,7 +145,7 @@ impl Epub {
})
} else {
let path = manifest.get("ncx").unwrap();
- let xml = self.get_text(rootdir.join(path).to_str().unwrap());
+ let xml = self.get_text(&format!("{}{}", rootdir, path));
let doc = Document::parse(&xml).unwrap();
doc.descendants()
@@ -179,7 +183,7 @@ impl Epub {
let id = n.attribute("idref").unwrap();
let path = manifest.remove(id).unwrap();
let label = nav.remove(path).unwrap_or_else(|| i.to_string());
- let path = rootdir.join(path).to_str().unwrap().to_string();
+ let path = format!("{}{}", rootdir, path);
(path, label)
})
.collect()