@@ -30,7 +30,7 @@ Functions for producing an ODT file from OpenDocument XML.
3030-}
3131module Text.Pandoc.ODT ( saveOpenDocumentAsODT ) where
3232import Text.Pandoc.Shared ( contentsOf )
33−import Data.Maybe ( fromJust )
33+import Data.Maybe ( fromJust, isJust )
3434import Data.List ( partition, intersperse )
3535import Prelude hiding ( writeFile, readFile )
3636import System.IO.UTF8
@@ -44,6 +44,7 @@ import Text.XML.Light.Cursor
4444import Text.Pandoc.Shared ( withTempDir )
4545import Network.URI ( isURI )
4646import qualified Data.ByteString.Char8 as B ( writeFile, pack )
47+import Control.Monad ( unless )
4748
4849-- | Produce an ODT file from OpenDocument XML.
4950saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced.
@@ -53,11 +54,8 @@ saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced.
5354saveOpenDocumentAsODT destinationODTPath sourceDirRelative xml = do
5455 let zipCmd = "zip"
5556 -- check for zip in path:
56− maybeZipPath <- findExecutable zipCmd
57− let zipPath = case maybeZipPath of
58− Just p -> p
59− Nothing -> error $ "The '" ++ zipCmd ++ "' command, which is needed to build an ODT file, " ++
60− "was not found.\n" ++
57+ findExecutable zipCmd >>= \v -> unless (isJust v) $ error $ "The '" ++ zipCmd ++
58+ "' command, which is needed to build an ODT file, was not found.\n" ++
6159 "It can be obtained from http://www.info-zip.org/Zip.html\n" ++
6260 "Debian (and Debian-based) linux: apt-get install zip\n" ++
6361 "Windows: See http://gnuwin32.sourceforge.net/packages/zip.htm"
@@ -70,7 +68,7 @@ saveOpenDocumentAsODT destinationODTPath sourceDirRelative xml = do
7068 writeFile (tempDir </> "content.xml") xml'
7169 oldDir <- getCurrentDirectory
7270 setCurrentDirectory tempDir
73− let zipCmdLine = zipPath ++ " -9 -q -r " ++ tempODT ++ " " ++ "content.xml Pictures"
71+ let zipCmdLine = "zip -9 -q -r " ++ tempODT ++ " " ++ "content.xml Pictures"
7472 ec <- runCommand zipCmdLine >>= waitForProcess -- this requires compilation with -threaded
7573 setCurrentDirectory oldDir
7674 case ec of