Shared: Fixed readDefaultDataFile so it works on Windows.

This commit is contained in:
John MacFarlane 2013-04-20 13:07:50 -07:00
parent 3c1a8d1924
commit 89d525e417

View file

@ -105,7 +105,7 @@ import Network.HTTP (findHeader, rspBody,
import Network.Browser (browse, setAllowRedirects, request)
#ifdef EMBED_DATA_FILES
import Text.Pandoc.Data (dataFiles)
import System.FilePath ( joinPath )
import System.FilePath ( joinPath, splitDirectories )
#else
import Paths_pandoc (getDataFileName)
#endif
@ -526,7 +526,7 @@ readDefaultDataFile fname =
Nothing -> ioError $ userError
$ "Data file `" ++ fname ++ "' does not exist"
Just contents -> return contents
where makeCanonical = joinPath . transformPathParts . splitBy (=='/')
where makeCanonical = joinPath . transformPathParts . splitDirectories
transformPathParts = reverse . foldl go []
go as "." = as
go (_:as) ".." = as