diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2010-01-18 07:21:10 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2010-01-18 07:21:10 +0000 |
commit | f0bfbc5508eac083a51ba961bf66225fd526f092 (patch) | |
tree | f401b843ca322dfbacb19d60f72271759f47e9e8 /src/Text/Pandoc | |
parent | 4cdb4c0b365a16efe2a6b7111a82cc1a723c0750 (diff) | |
download | pandoc-f0bfbc5508eac083a51ba961bf66225fd526f092.tar.gz |
Made userdir arg of saveDocumentAsODT a Maybe.
This way it's consistent with other data file retrieval
functions.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1823 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/ODT.hs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/Text/Pandoc/ODT.hs b/src/Text/Pandoc/ODT.hs index bd497d0b3..6d602fb2a 100644 --- a/src/Text/Pandoc/ODT.hs +++ b/src/Text/Pandoc/ODT.hs @@ -42,22 +42,25 @@ import System.Directory import Control.Monad (liftM) -- | Produce an ODT file from OpenDocument XML. -saveOpenDocumentAsODT :: FilePath -- ^ Path of user data directory - -> FilePath -- ^ Pathname of ODT file to be produced. - -> FilePath -- ^ Relative directory of source file. +saveOpenDocumentAsODT :: Maybe FilePath -- ^ Path of user data directory + -> FilePath -- ^ Pathname of ODT file to be produced + -> FilePath -- ^ Relative directory of source file -> Maybe FilePath -- ^ Path specified by --reference-odt - -> String -- ^ OpenDocument XML contents. + -> String -- ^ OpenDocument XML contents -> IO () saveOpenDocumentAsODT datadir destinationODTPath sourceDirRelative mbRefOdt xml = do refArchive <- liftM toArchive $ case mbRefOdt of Just f -> B.readFile f Nothing -> do - let userRefOdt = datadir </> "reference.odt" - userRefOdtExists <- doesFileExist userRefOdt - if userRefOdtExists - then B.readFile userRefOdt - else getDataFileName "reference.odt" >>= B.readFile + let defaultODT = getDataFileName "reference.odt" >>= B.readFile + case datadir of + Nothing -> defaultODT + Just d -> do + exists <- doesFileExist (d </> "reference.odt") + if exists + then B.readFile (d </> "reference.odt") + else defaultODT -- handle pictures let (newContents, pics) = case runParser pPictures [] "OpenDocument XML contents" xml of |