- protected MetaData getMeta(URL source, InputStream in) throws IOException {
- return super.getMeta(fakeSource, in);
- }
-
- @Override
- protected String getDesc(URL source, InputStream in) throws IOException {
- return super.getDesc(fakeSource, in);
- }
-
- @Override
- protected List<Entry<String, URL>> getChapters(URL source, InputStream in)
- throws IOException {
- return super.getChapters(fakeSource, in);
- }
-
- @Override
- protected String getChapterContent(URL source, InputStream in, int number)
- throws IOException {
- return super.getChapterContent(fakeSource, in, number);
- }
-
- @Override
- protected InputStream openInput(URL source) throws IOException {
- try {
- File fakeFile = new File(source.toURI()); // "story/index.html"
- fakeFile = new File(fakeFile.getParent()); // "story"
- fakeFile = new File(fakeFile, fakeFile.getName()); // "story/story"
- fakeSource = fakeFile.toURI().toURL();
- return new MarkableFileInputStream(new FileInputStream(fakeFile));
- } catch (URISyntaxException e) {
- throw new IOException(
- "file not supported (maybe not created with this program or corrupt)",
- e);
- } catch (MalformedURLException e) {
- throw new IOException("file not supported (bad URL)", e);
+ public URL getCanonicalUrl(URL source) throws IOException {
+ if (source.toString().endsWith(File.separator + "index.html")) {
+ try {
+ File fakeFile = new File(source.toURI()); // "story/index.html"
+ fakeFile = new File(fakeFile.getParent()); // "story"
+ fakeFile = new File(fakeFile, fakeFile.getName()); // "story/story"
+ return fakeFile.toURI().toURL();
+ } catch (URISyntaxException e) {
+ throw new IOException(
+ "file not supported (maybe not created with this program or corrupt)",
+ e);
+ }