moduleHSH.Helpers.FileManipwhereimportSystem.DirectoryimportSystem.FilePath(takeDirectory)importqualifiedData.ByteString.Char8asBimportHSHimportText.StringTemplate.HelpersimportHSH.Helpers.UnixUsers-- createDirectoryOwned-- write a file, creating parent directories if necessarywriteFileForceB=writeFileForce'B.writeFilewriteFileForce=writeFileForce'writeFilewriteFileForce'wfpcontents=docreateDirectoryIfMissingTrue(takeDirectoryfp)wfpcontents-- wrapper over ln -fsdataSymlinkArgs=SymLinkArgs{target::String,link::String}derivingShowsymlinkslArgs=runIO$render1[("target",targetslArgs),("link",linkslArgs)]"ln -fs $target$ $link$"-- | wrapper over find \/path\/to\/top\/dir -type dfindDirectories::FilePath->IO[FilePath]findDirectoriesd=runStrings$render1[("d",d)]"find $d$ -type d"runS::String->IOStringrunS=runrunStrings::String->IO[String]runStrings=(return.lines=<<).run-- I took this out because I don't like the behavior of doesFileExist when it comes to symlinks-- If symlink exists, but it's to a directlry, this test is false-- Or if it's to a nonexisting file, also false.-- yet, removeFile will work anyway, which seems contradictory-- ideally there should be functions removeSymlink, doesSymLink exist, and generally behavior around-- symlinks should be better documented{-
removeFileIfExists f = do
e <- doesFileExist f
if e
then removeFile f
else return ()
-}