From 0362298500b2efb7ad3ffe23f57f025573672799 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Fri, 1 Aug 2008 21:01:09 +0000 Subject: ODT writer: Don't use pathname in invoking "zip", as that causes problems in windows. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1363 788f1e2b-df1e-0410-8736-df70ead52e1b --- Text/Pandoc/ODT.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Text') diff --git a/Text/Pandoc/ODT.hs b/Text/Pandoc/ODT.hs index c83ccca65..bb49792eb 100644 --- a/Text/Pandoc/ODT.hs +++ b/Text/Pandoc/ODT.hs @@ -30,7 +30,7 @@ Functions for producing an ODT file from OpenDocument XML. -} module Text.Pandoc.ODT ( saveOpenDocumentAsODT ) where import Text.Pandoc.Shared ( contentsOf ) -import Data.Maybe ( fromJust ) +import Data.Maybe ( fromJust, isJust ) import Data.List ( partition, intersperse ) import Prelude hiding ( writeFile, readFile ) import System.IO.UTF8 @@ -44,6 +44,7 @@ import Text.XML.Light.Cursor import Text.Pandoc.Shared ( withTempDir ) import Network.URI ( isURI ) import qualified Data.ByteString.Char8 as B ( writeFile, pack ) +import Control.Monad ( unless ) -- | Produce an ODT file from OpenDocument XML. saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced. @@ -53,11 +54,8 @@ saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced. saveOpenDocumentAsODT destinationODTPath sourceDirRelative xml = do let zipCmd = "zip" -- check for zip in path: - maybeZipPath <- findExecutable zipCmd - let zipPath = case maybeZipPath of - Just p -> p - Nothing -> error $ "The '" ++ zipCmd ++ "' command, which is needed to build an ODT file, " ++ - "was not found.\n" ++ + findExecutable zipCmd >>= \v -> unless (isJust v) $ error $ "The '" ++ zipCmd ++ + "' command, which is needed to build an ODT file, was not found.\n" ++ "It can be obtained from http://www.info-zip.org/Zip.html\n" ++ "Debian (and Debian-based) linux: apt-get install zip\n" ++ "Windows: See http://gnuwin32.sourceforge.net/packages/zip.htm" @@ -70,7 +68,7 @@ saveOpenDocumentAsODT destinationODTPath sourceDirRelative xml = do writeFile (tempDir "content.xml") xml' oldDir <- getCurrentDirectory setCurrentDirectory tempDir - let zipCmdLine = zipPath ++ " -9 -q -r " ++ tempODT ++ " " ++ "content.xml Pictures" + let zipCmdLine = "zip -9 -q -r " ++ tempODT ++ " " ++ "content.xml Pictures" ec <- runCommand zipCmdLine >>= waitForProcess -- this requires compilation with -threaded setCurrentDirectory oldDir case ec of -- cgit v1.2.3