diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 35a854bf6..c1a55930c 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -92,7 +92,7 @@ module Text.Pandoc.Shared ( safeRead, safeStrRead, -- * User data directory - defaultUserDataDir, + defaultUserDataDirs, -- * Version pandocVersion ) where @@ -1017,13 +1017,15 @@ safeStrRead s = case reads s of -- is present, we return the XDG data directory. If the XDG data directory -- is not defined (e.g. because we are in an environment where $HOME is -- not defined), we return the empty string. -defaultUserDataDir :: IO FilePath -defaultUserDataDir = do +defaultUserDataDirs :: IO [FilePath] +defaultUserDataDirs = do xdgDir <- E.catch (getXdgDirectory XdgData "pandoc") (\(_ :: E.SomeException) -> return mempty) legacyDir <- getAppUserDataDirectory "pandoc" xdgExists <- doesDirectoryExist xdgDir legacyDirExists <- doesDirectoryExist legacyDir - if not xdgExists && legacyDirExists - then return legacyDir - else return xdgDir + let mainDir = if not xdgExists && legacyDirExists then legacyDir else xdgDir + xdgDirs <- E.catch (getXdgDirectoryList XdgDataDirs) + (\(_ :: E.SomeException) -> return mempty) + return (mainDir:xdgDirs) +