aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Class
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-06-03 18:34:38 -0600
committerJohn MacFarlane <jgm@berkeley.edu>2021-06-03 18:34:38 -0600
commitb6c04383e403b0962db09e6748760d3ec376f2ed (patch)
tree7271016a729012a6ddb5d1e93881ec433c621686 /src/Text/Pandoc/Class
parenta54a19cca5d00378f6103d0bb5a6e3ca2dcfef3c (diff)
downloadpandoc-b6c04383e403b0962db09e6748760d3ec376f2ed.tar.gz
T.P.Class.IO: normalise path in writeMedia.
This ensures that we get `\` separators on Windows.
Diffstat (limited to 'src/Text/Pandoc/Class')
-rw-r--r--src/Text/Pandoc/Class/IO.hs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Class/IO.hs b/src/Text/Pandoc/Class/IO.hs
index f12c0a938..6df39d4d0 100644
--- a/src/Text/Pandoc/Class/IO.hs
+++ b/src/Text/Pandoc/Class/IO.hs
@@ -211,13 +211,12 @@ writeMedia :: (PandocMonad m, MonadIO m)
=> FilePath -> MediaBag -> FilePath
-> m ()
writeMedia dir mediabag subpath = do
- -- we join and split to convert a/b/c to a\b\c on Windows;
- -- in zip containers all paths use /
let mbcontents = lookupMedia subpath mediabag
case mbcontents of
Nothing -> throwError $ PandocResourceNotFound $ pack subpath
Just item -> do
- let fullpath = dir </> mediaPath item
+ -- we normalize to get proper path separators for the platform
+ let fullpath = dir </> normalise (mediaPath item)
liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)
logIOError $ BL.writeFile fullpath $ mediaContents item