getDir' =<< getDataFileName "defaultPages"
where
getDir' :: FilePath -> IO (Set PageName)
- getDir' dirPath
- = getDirectoryContents (dirPath </> encodePageName dir)
- >>=
- return . S.fromList . map (m dirPath) . filter f
+ getDir' basePath
+ = do let childDirPath = basePath </> encodePageName dir
+ exists <- doesDirectoryExist childDirPath
+ if exists then
+ getDirectoryContents childDirPath
+ >>=
+ return . S.fromList . map (m basePath) . filter f
+ else
+ return S.empty
m :: FilePath -> FilePath -> PageName
- m dirPath = (dir </>) . decodePageName . makeRelative dirPath . dropExtension
+ m basePath = (dir </>) . decodePageName . makeRelative basePath . dropExtension
f :: FilePath -> Bool
f "." = False