Search in sources :

Example 1 with BookReadingException

use of org.geometerplus.fbreader.formats.BookReadingException in project FBReaderJ by geometer.

the class OEBNativePlugin method getOpfFile.

private ZLFile getOpfFile(ZLFile oebFile) throws BookReadingException {
    if ("opf".equals(oebFile.getExtension())) {
        return oebFile;
    }
    final ZLFile containerInfoFile = ZLFile.createFile(oebFile, "META-INF/container.xml");
    if (containerInfoFile.exists()) {
        final ContainerFileReader reader = new ContainerFileReader();
        reader.readQuietly(containerInfoFile);
        final String opfPath = reader.getRootPath();
        if (opfPath != null) {
            return ZLFile.createFile(oebFile, opfPath);
        }
    }
    for (ZLFile child : oebFile.children()) {
        if (child.getExtension().equals("opf")) {
            return child;
        }
    }
    throw new BookReadingException("opfFileNotFound", oebFile);
}
Also used : BookReadingException(org.geometerplus.fbreader.formats.BookReadingException) ZLFile(org.geometerplus.zlibrary.core.filesystem.ZLFile)

Aggregations

BookReadingException (org.geometerplus.fbreader.formats.BookReadingException)1 ZLFile (org.geometerplus.zlibrary.core.filesystem.ZLFile)1