@@ -42,22 +42,25 @@ import System.Directory
4242import Control.Monad (liftM)
4343
4444-- | Produce an ODT file from OpenDocument XML.
45−saveOpenDocumentAsODT :: FilePath -- ^ Path of user data directory
46− -> FilePath -- ^ Pathname of ODT file to be produced.
47− -> FilePath -- ^ Relative directory of source file.
45+saveOpenDocumentAsODT :: Maybe FilePath -- ^ Path of user data directory
46+ -> FilePath -- ^ Pathname of ODT file to be produced
47+ -> FilePath -- ^ Relative directory of source file
4848 -> Maybe FilePath -- ^ Path specified by --reference-odt
49− -> String -- ^ OpenDocument XML contents.
49+ -> String -- ^ OpenDocument XML contents
5050 -> IO ()
5151saveOpenDocumentAsODT datadir destinationODTPath sourceDirRelative mbRefOdt xml = do
5252 refArchive <- liftM toArchive $
5353 case mbRefOdt of
5454 Just f -> B.readFile f
5555 Nothing -> do
56− let userRefOdt = datadir </> "reference.odt"
57− userRefOdtExists <- doesFileExist userRefOdt
58− if userRefOdtExists
59− then B.readFile userRefOdt
60− else getDataFileName "reference.odt" >>= B.readFile
56+ let defaultODT = getDataFileName "reference.odt" >>= B.readFile
57+ case datadir of
58+ Nothing -> defaultODT
59+ Just d -> do
60+ exists <- doesFileExist (d </> "reference.odt")
61+ if exists
62+ then B.readFile (d </> "reference.odt")
63+ else defaultODT
6164 -- handle pictures
6265 let (newContents, pics) =
6366 case runParser pPictures [] "OpenDocument XML contents" xml of