diff --git a/app/EpubParser.hs b/app/EpubParser.hs index 83dd59b..a83bfb9 100644 --- a/app/EpubParser.hs +++ b/app/EpubParser.hs @@ -6,3 +6,9 @@ import qualified Data.ByteString.Lazy.Char8 as C8 openEpub :: FilePath -> IO (Either String Archive) openEpub path = toArchive <$> BL.readFile path >>= \archive -> maybe (pure $ Left "Error reading file") (\entry -> if fromEntry entry == C8.pack "application/epub+zip" then pure (Right archive) else pure (Left "Wrong mimetype")) (findEntryByPath "mimetype" archive) + +getOpfPath :: Archive -> Maybe FilePath +getOpfPath archive = do + entry <- findEntryByPath "META-INF/container.xml" archive + + return "OEBPS/content.opf" diff --git a/svitak.cabal b/svitak.cabal index ee91af7..3aa8b40 100644 --- a/svitak.cabal +++ b/svitak.cabal @@ -54,24 +54,16 @@ common warnings ghc-options: -Wall executable svitak - -- Import common warning flags. import: warnings - - -- .hs or .lhs file containing the Main module. main-is: Main.hs - -- Modules included in this executable, other than Main. - -- other-modules: + other-modules: EpubParser - -- LANGUAGE extensions used by modules in this package. - -- other-extensions: - - -- Other library packages from which modules are imported. build-depends: base ^>=4.21.0.0, - epub-metadata >=5.4 + bytestring >= 0.12.2.0, + epub-metadata >=5.4, + zip-archive >= 0.4.3.2, + tagsoup - -- Directories containing source files. hs-source-dirs: app - - -- Base language which the package is written in. default-language: Haskell2010