getAllFilesMatching: increase malleability factor by a notch;
just warn if an element along the import search path doesn't
exist, don't barf.
import Util
import Outputable
import DirUtils ( getDirectoryContents )
import Util
import Outputable
import DirUtils ( getDirectoryContents )
+import IO ( hPutStrLn, stderr, isDoesNotExistError )
infixr 9 `thenRn`, `thenRn_`
\end{code}
infixr 9 `thenRn`, `thenRn_`
\end{code}
| otherwise = old_path -- don't warn about innocous shadowings.
getAllFilesMatching :: FilePath -> String -> IO [(String, FilePath)]
| otherwise = old_path -- don't warn about innocous shadowings.
getAllFilesMatching :: FilePath -> String -> IO [(String, FilePath)]
-getAllFilesMatching dir_path suffix = do
+getAllFilesMatching dir_path suffix = (do
fpaths <- getDirectoryContents dir_path
-- fpaths entries do not have dir_path prepended
return (mapMaybe withSuffix fpaths)
fpaths <- getDirectoryContents dir_path
-- fpaths entries do not have dir_path prepended
return (mapMaybe withSuffix fpaths)
+ ) -- soft failure
+ `catch`
+ (\ err -> do
+ hPutStrLn stderr
+ ("Import path element `" ++ dir_path ++
+ if (isDoesNotExistError err) then
+ "' does not exist, ignoring."
+ else
+ "' couldn't read, ignoring.")
+
+ return []
+ )
where
xiffus = reverse dotted_suffix
where
xiffus = reverse dotted_suffix