Updated cabal file and new function

This commit is contained in:
Marko Andjelic 2026-01-23 22:37:35 +00:00
commit 0ac0ae8d61
2 changed files with 11 additions and 13 deletions

View file

@ -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"

View file

@ -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