X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FEpub.java;h=794998e0d75c24ed36288aec9dcb7c846ecd93fd;hb=2aac79c740789071ad9b773d25f20e103f0da86c;hp=9b06f202f965e82782f3acf98607d9bf6c37ac65;hpb=0ffa47548f474c1330d8d723300d9aa7a4894736;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/supported/Epub.java b/src/be/nikiroo/fanfix/supported/Epub.java index 9b06f20..794998e 100644 --- a/src/be/nikiroo/fanfix/supported/Epub.java +++ b/src/be/nikiroo/fanfix/supported/Epub.java @@ -28,6 +28,7 @@ import be.nikiroo.utils.StringUtils; */ class Epub extends InfoText { protected MetaData meta; + private File tmpDir; private File tmp; private String desc; @@ -93,8 +94,9 @@ class Epub extends InfoText { protected void preprocess(URL source, InputStream in) throws IOException { // Note: do NOT close this stream, as it would also close "in" ZipInputStream zipIn = new ZipInputStream(in); - tmp = File.createTempFile("fanfic-reader-parser_", ".tmp"); - File tmpInfo = new File(tmp + ".info"); + tmpDir = Instance.getTempFiles().createTempDir("fanfic-reader-parser"); + tmp = new File(tmpDir, "file.txt"); + File tmpInfo = new File(tmpDir, "file.info"); fakeSource = tmp.toURI().toURL(); Image cover = null; @@ -189,24 +191,24 @@ class Epub extends InfoText { } meta = new MetaData(); - meta.setLang("EN"); + meta.setLang("en"); meta.setTags(new ArrayList()); meta.setSource(getSourceName()); meta.setUuid(url); meta.setUrl(url); meta.setTitle(title); meta.setAuthor(author); + meta.setImageDocument(isImagesDocumentByDefault()); } } @Override protected void close() { - if (tmp != null && tmp.exists()) { - if (!tmp.delete()) { - tmp.deleteOnExit(); - } + if (tmpDir != null) { + IOUtils.deltree(tmpDir); } + tmpDir = null; tmp = null; if (fakeIn != null) { @@ -231,4 +233,8 @@ class Epub extends InfoText { protected boolean getCover() { return true; } + + protected boolean isImagesDocumentByDefault() { + return false; + } }