M hurl.cabal => hurl.cabal +1 -1
@@ 104,4 104,4 @@ library
if flag(freedesktop)
CPP-options: -DWITH_XDG
build-depends: filepath, directory, process >= 1.2 && <2.0
- other-modules: Network.URI.XDG.Ini, Network.URI.XDG.MimeApps, Network.URI.XDG.DesktopEntry
+ other-modules: Network.URI.XDG.Ini, Network.URI.XDG.MimeApps, Network.URI.XDG.DesktopEntry, Network.URI.XDG
M src/Network/URI/Fetch.hs => src/Network/URI/Fetch.hs +3 -4
@@ 132,11 132,10 @@ fetchURL Session {locale = l} _ URI {uriScheme = scheme} =
dispatchByMIME :: Session -> String -> URI -> IO (Maybe String)
#if WITH_XDG
-dispatchByMIME Session {locale = l, apps = a} mime uri
- | canDispatchMIME a mime = dispatchURIByMIME l a uri mime
-#endif
-
+dispatchByMIME Session {locale = l, apps = a} mime uri = dispatchURIByMIME l a uri mime
+#else
dispatchByMIME _ _ _ = return Nothing
+#endif
#ifdef WITH_DATA_URI
breakOn c (a:as) | c == a = ([], as)
M src/Network/URI/XDG/MimeApps.hs => src/Network/URI/XDG/MimeApps.hs +7 -1
@@ 2,6 2,7 @@ module Network.URI.XDG.MimeApps(HandlersConfig, loadHandlers, queryHandlers, spl
import System.Environment (lookupEnv)
import Control.Monad (forM)
+import Control.Exception (catch)
import System.FilePath
import Data.List (nub, (\\))
import System.Directory (getHomeDirectory)
@@ 16,9 17,14 @@ loadHandlers = do
dir0 <- mimeAppsDirs "XDG_CONFIG" ".config" "/etc/xdg"
dir1 <- mimeAppsDirs "XDG_DATA" ".local/share" "/usr/local/share/:/usr/share/"
let filepaths = mimeAppsFiles (dir0 ++ map (</> "applications") dir1) desktop
- files <- forM filepaths readFile
+ files <- forM filepaths tryReadFile
return $ map parseIni files
+tryReadFile path = readFile path `catch` handler
+ where
+ handler :: IOError -> IO String
+ handler e = return ""
+
mimeAppsDirs envPrefix defaultHome defaultDirs = do
home <- lookupEnv (envPrefix ++ "_HOME")
dirs <- lookupEnv (envPrefix ++ "_DIRS")