mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-26 10:16:32 +00:00
T.P.Class.IO: normalise path in writeMedia.
This ensures that we get `\` separators on Windows.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user